WebPartDescription.Title 属性
定义
public:
property System::String ^ Title { System::String ^ get(); };
public string Title { get; }
member this.Title : string
Public ReadOnly Property Title As String
属性值
字符串,包含相应控件的标题。A string that contains the title of the corresponding control. 默认值是一个计算出的字符串,由 .NET Framework 提供。The default value is a calculated string supplied by the .NET Framework.
示例
下面的代码示例演示如何以编程方式使用 Title 属性。The following code example demonstrates programmatic use of the Title property. 有关运行此代码示例所需的完整代码,请参阅类概述主题的 "示例" 部分 WebPartDescription 。For the full code required to run this code example, see the Example section of the WebPartDescription class overview topic.
网页的方法中的以下代码 Button1_Click 演示了如何 WebPartDescription 使用方法获取目录中的对象集合 GetAvailableWebPartDescriptions ,然后 WebPart 通过循环遍历对象来显示目录中每个控件的详细信息 WebPartDescription 。The following code in the Button1_Click method of a Web page demonstrates how to get the collection of WebPartDescription objects in a catalog using the GetAvailableWebPartDescriptions method, and then to display the details of each WebPart control in the catalog by looping through the WebPartDescription objects. 请注意,将 Title 在以下代码中检索属性值。Note that the Title property value is retrieved in the following code.
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = String.Empty;
WebPartDescriptionCollection descriptions =
DeclarativeCatalogPart1.GetAvailableWebPartDescriptions();
foreach (WebPartDescription desc in descriptions)
{
Label1.Text += "ID: " + desc.ID + "<br />" +
"Title: " + desc.Title + "<br />" +
"Description: " + desc.Description + "<br />" +
"ImageUrl: " + desc.CatalogIconImageUrl + "<br />" +
"<hr />";
}
}
Protected Sub Button1_Click(ByVal sender As Object, _
ByVal e As System.EventArgs)
Label1.Text = String.Empty
Dim descriptions As WebPartDescriptionCollection = _
DeclarativeCatalogPart1.GetAvailableWebPartDescriptions()
Dim desc As WebPartDescription
For Each desc In descriptions
Label1.Text += "ID: " & desc.ID & "<br />" & _
"Title: " & desc.Title & "<br />" & _
"Description: " & desc.Description & "<br />" & _
"ImageUrl: " & desc.CatalogIconImageUrl & "<br />" & _
"<hr />"
Next
End Sub
注解
属性的值 Title 直接对应于 WebPart.DisplayTitle 属性。The value of the Title property corresponds directly to the WebPart.DisplayTitle property. 如果相应的 WebPart 控件具有其属性的任何 DisplayTitle 值,则将成为属性的值 Title ; 否则,该标题为计算值。Whatever the corresponding WebPart control has for its DisplayTitle property, that becomes the value of the Title property; otherwise, the title is a calculated value.
Title仅当页处于目录显示模式并且 WebPart 控件在控件目录中显示时,此属性才适用。The Title property applies only when a page is in catalog display mode, and a WebPart control is being displayed in a catalog of controls. 分配给控件的任何标题 WebPart 将显示在目录中该控件的旁边。Whatever title is assigned to a WebPart control appears next to the control in the catalog.