本文整理汇总了C#中System.Web.UI.ControlBuilder.OnAppendToParentBuilder方法的典型用法代码示例。如果您正苦于以下问题:C# ControlBuilder.OnAppendToParentBuilder方法的具体用法?C# ControlBuilder.OnAppendToParentBuilder怎么用?C# ControlBuilder.OnAppendToParentBuilder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.ControlBuilder
的用法示例。
在下文中一共展示了ControlBuilder.OnAppendToParentBuilder方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AppendSubBuilder
/// <devdoc>
///
/// </devdoc>
public virtual void AppendSubBuilder(ControlBuilder subBuilder) {
// Tell the sub builder that it's about to be appended to its parent
subBuilder.OnAppendToParentBuilder(this);
if (FChildrenAsProperties) {
// Don't allow code blocks when properties are expected (ASURT 97838)
if (subBuilder is CodeBlockBuilder) {
throw new HttpException(SR.GetString(SR.Code_not_supported_on_not_controls));
}
// If there is a default property, delegate to its builder
if (DefaultPropertyBuilder != null) {
DefaultPropertyBuilder.AppendSubBuilder(subBuilder);
return;
}
// The tagname is the property name
string propName = subBuilder.TagName;
if (subBuilder is TemplateBuilder) {
TemplateBuilder tplBuilder = (TemplateBuilder)subBuilder;
AddTemplateProperty(tplBuilder.Filter, propName, tplBuilder);
}
else if (subBuilder is CollectionBuilder) {
// If there are items in the collection, add them
if ((subBuilder.SubBuilders != null) && (subBuilder.SubBuilders.Count > 0)) {
IEnumerator subBuilders = subBuilder.SubBuilders.GetEnumerator();
while (subBuilders.MoveNext()) {
ControlBuilder builder = (ControlBuilder)subBuilders.Current;
subBuilder.AddCollectionItem(builder);
}
subBuilder.SubBuilders.Clear();
AddComplexProperty(subBuilder.Filter, propName, subBuilder);
}
}
else if (subBuilder is StringPropertyBuilder) {
// Trim this so whitespace doesn't matter inside a tag?
string text = ((StringPropertyBuilder)subBuilder).Text.Trim();
if (!String.IsNullOrEmpty(text)) {
// Make sure we haven't set this property in the attributes already (special case for TextBox and similar things)
AddComplexProperty(subBuilder.Filter, propName, subBuilder);
}
}
else {
AddComplexProperty(subBuilder.Filter, propName, subBuilder);
}
return;
}
CodeBlockBuilder codeBlockBuilder = subBuilder as CodeBlockBuilder;
if (codeBlockBuilder != null) {
// Don't allow code blocks inside non-control tags (ASURT 76719)
if (ControlType != null && !flags[controlTypeIsControl]) {
throw new HttpException(SR.GetString(SR.Code_not_supported_on_not_controls));
}
// Is it a databinding expression? <%# ... %>
if (codeBlockBuilder.BlockType == CodeBlockType.DataBinding) {
// Bind statements are not allowed as DataBoundLiterals inside any template.
// Outside a template, they should be treated as calls to page code.
Match match;
if ((match = bindExpressionRegex.Match(codeBlockBuilder.Content, 0)).Success || (match = bindItemExpressionRegex.Match(codeBlockBuilder.Content, 0)).Success) {
ControlBuilder currentBuilder = this;
while (currentBuilder != null && !(currentBuilder is TemplateBuilder)) {
currentBuilder = currentBuilder.ParentBuilder;
}
if (currentBuilder != null && currentBuilder.ParentBuilder != null && currentBuilder is TemplateBuilder) {
throw new HttpException(SR.GetString(SR.DataBoundLiterals_cant_bind));
}
}
if (InDesigner) {
// In the designer, don't use the fancy multipart DataBoundLiteralControl,
// which breaks a number of things (ASURT 82925,86738). Instead, use the
// simpler DesignerDataBoundLiteralControl, and do standard databinding
// on its Text property.
IDictionary attribs = new ParsedAttributeCollection();
attribs.Add("Text", "<%#" + codeBlockBuilder.Content + "%>");
subBuilder = CreateBuilderFromType(Parser, this, typeof(DesignerDataBoundLiteralControl),
null, null, attribs, codeBlockBuilder.Line, codeBlockBuilder.PageVirtualPath);
}
else {
// Get the last builder, and check if it's a DataBoundLiteralControlBuilder
object lastBuilder = GetLastBuilder();
DataBoundLiteralControlBuilder dataBoundBuilder = lastBuilder as DataBoundLiteralControlBuilder;
// If not, then we need to create one. Otherwise, just append to the
//.........这里部分代码省略.........
示例2: AppendSubBuilder
public virtual void AppendSubBuilder (ControlBuilder subBuilder)
{
subBuilder.OnAppendToParentBuilder (this);
subBuilder.parentBuilder = this;
if (childrenAsProperties) {
AppendToProperty (subBuilder);
return;
}
if (typeof (CodeRenderBuilder).IsAssignableFrom (subBuilder.GetType ())) {
AppendCode (subBuilder);
return;
}
AddChild (subBuilder);
}
示例3: AppendSubBuilder
public virtual void AppendSubBuilder(ControlBuilder subBuilder)
{
subBuilder.OnAppendToParentBuilder(this);
if (this.FChildrenAsProperties)
{
if (subBuilder is CodeBlockBuilder)
{
throw new HttpException(System.Web.SR.GetString("Code_not_supported_on_not_controls"));
}
if (this.DefaultPropertyBuilder != null)
{
this.DefaultPropertyBuilder.AppendSubBuilder(subBuilder);
}
else
{
string tagName = subBuilder.TagName;
if (subBuilder is TemplateBuilder)
{
TemplateBuilder builder = (TemplateBuilder) subBuilder;
this.AddTemplateProperty(builder.Filter, tagName, builder);
}
else if (subBuilder is CollectionBuilder)
{
if ((subBuilder.SubBuilders != null) && (subBuilder.SubBuilders.Count > 0))
{
IEnumerator enumerator = subBuilder.SubBuilders.GetEnumerator();
while (enumerator.MoveNext())
{
ControlBuilder current = (ControlBuilder) enumerator.Current;
subBuilder.AddCollectionItem(current);
}
subBuilder.SubBuilders.Clear();
this.AddComplexProperty(subBuilder.Filter, tagName, subBuilder);
}
}
else if (subBuilder is StringPropertyBuilder)
{
if (!string.IsNullOrEmpty(((StringPropertyBuilder) subBuilder).Text.Trim()))
{
this.AddComplexProperty(subBuilder.Filter, tagName, subBuilder);
}
}
else
{
this.AddComplexProperty(subBuilder.Filter, tagName, subBuilder);
}
}
}
else
{
CodeBlockBuilder codeBlockBuilder = subBuilder as CodeBlockBuilder;
if (codeBlockBuilder != null)
{
if ((this.ControlType != null) && !this.flags[0x2000])
{
throw new HttpException(System.Web.SR.GetString("Code_not_supported_on_not_controls"));
}
if (codeBlockBuilder.BlockType == CodeBlockType.DataBinding)
{
if (bindExpressionRegex.Match(codeBlockBuilder.Content, 0).Success)
{
ControlBuilder parentBuilder = this;
while ((parentBuilder != null) && !(parentBuilder is TemplateBuilder))
{
parentBuilder = parentBuilder.ParentBuilder;
}
if (((parentBuilder != null) && (parentBuilder.ParentBuilder != null)) && (parentBuilder is TemplateBuilder))
{
throw new HttpException(System.Web.SR.GetString("DataBoundLiterals_cant_bind"));
}
}
if (this.InDesigner)
{
IDictionary attribs = new ParsedAttributeCollection();
attribs.Add("Text", "<%#" + codeBlockBuilder.Content + "%>");
subBuilder = CreateBuilderFromType(this.Parser, this, typeof(DesignerDataBoundLiteralControl), null, null, attribs, codeBlockBuilder.Line, codeBlockBuilder.PageVirtualPath);
}
else
{
object lastBuilder = this.GetLastBuilder();
DataBoundLiteralControlBuilder builder5 = lastBuilder as DataBoundLiteralControlBuilder;
bool flag = false;
if (builder5 == null)
{
builder5 = new DataBoundLiteralControlBuilder();
builder5.Init(this.Parser, this, typeof(DataBoundLiteralControl), null, null, null);
builder5.Line = codeBlockBuilder.Line;
builder5.VirtualPath = codeBlockBuilder.VirtualPath;
flag = true;
string s = lastBuilder as string;
if (s != null)
{
this.SubBuilders.RemoveAt(this.SubBuilders.Count - 1);
builder5.AddLiteralString(s);
}
}
builder5.AddDataBindingExpression(codeBlockBuilder);
if (!flag)
{
return;
//.........这里部分代码省略.........