Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="writer"></param>
        protected override void Render(HtmlTextWriter writer)
        {
            base.Render(writer);
            controlToRender.Attributes.Add("id", this.DomId);
            controlToRender.Attributes.Add("jsonid", this.JsonId);
            if (PopulateInline)
            {
                if (string.IsNullOrEmpty(this.VirtualBoxPath))
                {
                    throw new JsonInvalidOperationException("The VirtualBoxPath property was not set or the BoxName specified could not be found.");
                }

                controlToRender.Controls.Add(new LiteralControl(BoxServer.GetHtmlString(this.VirtualBoxPath)));
            }

            controlToRender.RenderControl(writer);

            if (PopulateOnPageLoad)
            {
                JsonFunction retrieveBoxContentScript = new JsonFunction();
                retrieveBoxContentScript.ExecutionType = JavascriptExecutionTypes.OnWindowLoad;
                retrieveBoxContentScript.FunctionBody  = string.Format("DataBox.GetBoxContent('{0}', '{1}');", this.DomId, this.BoxName);
                retrieveBoxContentScript.RenderControl(writer);
            }
        }
Example #2
0
        public string Template <T, PropType>(string propertyName, string templateName) where T : class
        {
            PropType propVal = Data <T>().DataProp <T, PropType>(propertyName);

            if (propVal == null)
            {
                return(string.Empty);
            }
            string      path = BoxServer.GetVirtualDataBoxPath(HttpContext.Current, typeof(PropType), templateName);
            BoxResponse resp = BoxServer.GetBoxResponse(HttpContext.Current, path, propVal);

            return(resp.Html);
        }
Example #3
0
        public string TemplateIEnumerable <T, PropType>(string propertyName, string templateName) where T : class
        {
            string retVal = string.Empty;
            IEnumerable <PropType> arr = Data <T>().DataProp <T, IEnumerable <PropType> >(propertyName);

            if (arr == null)
            {
                return(string.Empty);
            }
            string path = BoxServer.GetVirtualDataBoxPath(HttpContext.Current, typeof(PropType), templateName);

            foreach (PropType p in arr)
            {
                retVal += BoxServer.GetBoxResponse(HttpContext.Current, path, p).Html;
            }

            return(retVal);
        }