/// <exclude /> protected override void OnInit(System.EventArgs e) { XhtmlDocument feature = PageTemplateFeatureFacade.GetPageTemplateFeature(this.Name); FunctionContextContainer functionContextContainer = PageRenderer.GetPageRenderFunctionContextContainer(); var markup = new Markup(feature.Root, functionContextContainer); Controls.Add(markup); base.OnInit(e); }
/// <exclude /> protected override void OnInit(EventArgs e) { Type returnType; object result; string functionName = Name; var functionContextContainer = PageRenderer.GetPageRenderFunctionContextContainer(); try { result = GetValue(functionContextContainer, out returnType); } catch (Exception ex) { XElement errorBoxHtml; if (!functionContextContainer.ProcessException(functionName, ex, LogTitle, out errorBoxHtml)) { throw; } result = errorBoxHtml; returnType = typeof(XElement); } if (result != null) { if (returnType == typeof(XElement) || returnType == typeof(XhtmlDocument)) { var element = ValueTypeConverter.Convert<XElement>(result); var markup = new Markup(element, functionContextContainer); Controls.Add(markup); } else if (typeof(Control).IsAssignableFrom(returnType)) { var control = (Control) result; Controls.Add(control); } else if (result is IEnumerable<XNode>) { var nodes = result as IEnumerable<XNode>; foreach (XNode node in nodes) { if (node == null) continue; if (node is XElement) { var markup = new Markup(node as XElement, functionContextContainer); Controls.Add(markup); } else { Controls.Add(new LiteralControl(node.ToString())); } } } else if (result is XAttribute) { var parentControl = this.Parent as HtmlGenericControl; if(parentControl != null) { var attr = (XAttribute) result; parentControl.Attributes.Add(attr.Name.ToString(), attr.Value); } else { const string comment = @"<!-- Failed to add attribute, parent control should be of type HtmlGenericControl, check that runat=""server"" attribute is added -->"; Controls.Add(new LiteralControl(comment)); } } else { var str = result.ToString(); Controls.Add(new LiteralControl(str)); } } base.OnInit(e); }
/// <exclude /> protected override void OnInit(EventArgs e) { Type returnType; object result; string functionName = Name; var functionContextContainer = PageRenderer.GetPageRenderFunctionContextContainer(); try { result = GetValue(functionContextContainer, out returnType); } catch (Exception ex) { XElement errorBoxHtml; if (!functionContextContainer.ProcessException(functionName, ex, LogTitle, out errorBoxHtml)) { throw; } result = errorBoxHtml; returnType = typeof(XElement); } if (result != null) { if (returnType == typeof(XElement) || returnType == typeof(XhtmlDocument)) { var element = ValueTypeConverter.Convert <XElement>(result); var markup = new Markup(element, functionContextContainer); Controls.Add(markup); } else if (typeof(Control).IsAssignableFrom(returnType)) { var control = (Control)result; Controls.Add(control); } else if (result is IEnumerable <XNode> ) { var nodes = result as IEnumerable <XNode>; foreach (XNode node in nodes) { if (node == null) { continue; } if (node is XElement) { var markup = new Markup(node as XElement, functionContextContainer); Controls.Add(markup); } else { Controls.Add(new LiteralControl(node.ToString())); } } } else if (result is XAttribute) { var parentControl = this.Parent as HtmlGenericControl; if (parentControl != null) { var attr = (XAttribute)result; parentControl.Attributes.Add(attr.Name.ToString(), attr.Value); } else { const string comment = @"<!-- Failed to add attribute, parent control should be of type HtmlGenericControl, check that runat=""server"" attribute is added -->"; Controls.Add(new LiteralControl(comment)); } } else { var str = result.ToString(); Controls.Add(new LiteralControl(str)); } } base.OnInit(e); }