GenericWebPart.ChildControl 属性
定义
获取对子控件的引用,该子控件在运行时将由 GenericWebPart 控件包装。Gets a reference to the child control that is wrapped by a GenericWebPart control at run time.
public:
property System::Web::UI::Control ^ ChildControl { System::Web::UI::Control ^ get(); };
public System.Web.UI.Control ChildControl { get; }
member this.ChildControl : System.Web.UI.Control
Public ReadOnly Property ChildControl As Control
属性值
引用被包装的子控件的 Control。A Control that refers to the wrapped child control.
示例
下面的代码示例演示如何以编程方式使用 ChildControl 属性。The following code example demonstrates programmatic use of the ChildControl property. ChildControl以编程方式访问属性以检索有关控件的子控件的信息 GenericWebPart 。The ChildControl property is accessed programmatically to retrieve information about the child control of a GenericWebPart control. 该示例的完整源代码位于概述主题的 "示例" 部分 GenericWebPart 。The complete source code for the example is found in the Example section of the GenericWebPart overview topic.
protected void Button1_Click(object sender, EventArgs e)
{
Label2.Text =
@"<h3>Calendar GenericWebPart Properties</h3>" +
"<em>Title: </em>" + calendarPart.Title +
"<br />" +
"<em>CatalogIconImageUrl: </em>" + calendarPart.CatalogIconImageUrl +
"<br />" +
"<em>TitleUrl: </em>" + calendarPart.TitleUrl +
"<br />" +
"<em>Decription: </em>" + calendarPart.Description +
"<br />" +
"<em>TitleIconImageUrl: </em>" + calendarPart.TitleIconImageUrl +
"<br />" +
"<em>ChildControl ID: </em>" + calendarPart.ChildControl.ID +
"<br />" +
"<em>ChildControl Type: </em>" + calendarPart.ChildControl.GetType().Name +
"<br />" +
"<em>GenericWebPart ID: </em>" + calendarPart.ID +
"<br />" +
"<em>GenericWebPart Type: </em>" + calendarPart.GetType().Name +
"<br />" +
"<em>GenericWebPart Parent ID: </em>" + calendarPart.Parent.ID;
Label3.Text =
@"<h3>BulletedList GenericWebPart Properties</h3>" +
"<em>Title: </em>" + listPart.Title +
"<br />" +
"<em>CatalogIconImageUrl: </em>" + listPart.CatalogIconImageUrl +
"<br />" +
"<em>TitleUrl: </em>" + listPart.TitleUrl +
"<br />" +
"<em>Decription: </em>" + listPart.Description +
"<br />" +
"<em>TitleIconImageUrl: </em>" + listPart.TitleIconImageUrl +
"<br />" +
"<em>ChildControl ID: </em>" + listPart.ChildControl.ID +
"<br />" +
"<em>ChildControl Type: </em>" + listPart.ChildControl.GetType().Name +
"<br />" +
"<em>GenericWebPart ID: </em>" + listPart.ID +
"<br />" +
"<em>GenericWebPart Type: </em>" + listPart.GetType().Name +
"<br />" +
"<em>GenericWebPart Parent ID: </em>" + listPart.Parent.ID;
}
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
Label2.Text = _
"<h3>Calendar GenericWebPart Properties</h3>" & _
"<em>Title: </em>" & calendarPart.Title & _
"<br />" & _
"<em>CatalogIconImageUrl: </em>" & calendarPart.CatalogIconImageUrl & _
"<br />" & _
"<em>TitleUrl: </em>" & calendarPart.TitleUrl & _
"<br />" & _
"<em>Decription: </em>" & calendarPart.Description & _
"<br />" & _
"<em>TitleIconImageUrl: </em>" & calendarPart.TitleIconImageUrl & _
"<br />" & _
"<em>ChildControl ID: </em>" & calendarPart.ChildControl.ID & _
"<br />" & _
"<em>ChildControl Type: </em>" & calendarPart.ChildControl.GetType().Name & _
"<br />" & _
"<em>GenericWebPart ID: </em>" & calendarPart.ID & _
"<br />" & _
"<em>GenericWebPart Type: </em>" & calendarPart.GetType().Name & _
"<br />" & _
"<em>GenericWebPart Parent ID: </em>" & calendarPart.Parent.ID
Label3.Text = _
"<h3>BulletedList GenericWebPart Properties</h3>" & _
"<em>Title: </em>" & listPart.Title & _
"<br />" & _
"<em>CatalogIconImageUrl: </em>" & listPart.CatalogIconImageUrl & _
"<br />" & _
"<em>TitleUrl: </em>" & listPart.TitleUrl & _
"<br />" & _
"<em>Decription: </em>" & listPart.Description & _
"<br />" & _
"<em>TitleIconImageUrl: </em>" & listPart.TitleIconImageUrl & _
"<br />" & _
"<em>ChildControl ID: </em>" & listPart.ChildControl.ID & _
"<br />" & _
"<em>ChildControl Type: </em>" & listPart.ChildControl.GetType().Name & _
"<br />" & _
"<em>GenericWebPart ID: </em>" & listPart.ID & _
"<br />" & _
"<em>GenericWebPart Type: </em>" & listPart.GetType().Name & _
"<br />" & _
"<em>GenericWebPart Parent ID: </em>" & listPart.Parent.ID
End Sub
End Class
注解
ChildControl属性提供访问由控件包装的子控件的方法 GenericWebPart 。The ChildControl property provides the means to access the child control wrapped by a GenericWebPart control. 例如, WebPartManager 控件使用 ChildControl 属性从子控件提取个性化设置数据。For example, the WebPartManager control uses the ChildControl property to extract personalization data from the child control.