Прочитать на английском

Поделиться через


ControlBuilder.GetChildControlType(String, IDictionary) Метод

Определение

Получает Type типа элемента управления, соответствующего тегу дочернего элемента. Этот метод вызывается платформой страницы ASP.NET.

public virtual Type GetChildControlType (string tagName, System.Collections.IDictionary attribs);

Параметры

tagName
String

Имя тега дочернего элемента.

attribs
IDictionary

Массив атрибутов, содержащихся в дочернем элементе управления.

Возвращаемое значение

Type

Type указанного дочернего элемента управления.

Примеры

// Create a custom ControlBuilder that interprets nested elements
// named myitem as TextBoxes. If this class is called in a 
// ControlBuilderAttribute applied to a custom control, when
// that control is created in a page and it contains child elements
// that are named myitem, the child elements will be rendered as 
// TextBox server controls. This control builder also ignores literal
// strings between elements when it is associated with a control.
[AspNetHostingPermission(SecurityAction.Demand, 
   Level=AspNetHostingPermissionLevel.Minimal)]
public sealed class MyItemControlBuilder : ControlBuilder 
{
   // Override the GetChildControlType method to detect
   // child elements named myitem.
   public override Type GetChildControlType(String tagName,
                                     IDictionary attributes)
   {
      if (String.Compare(tagName, "myitem", true) == 0) 
      {
         return typeof(TextBox);
      }
      return null;
   }

   // Override the AppendLiteralString method so that literal
   // text between rows of controls are ignored.  
   public override void AppendLiteralString(string s) 
   {
     // Ignores literals between rows.
   }
}

Комментарии

Этот метод вызывается платформой страниц ASP.NET во время синтаксического анализа и не предназначен для непосредственного вызова в коде.

Применяется к

Продукт Версии
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8