語言

WebPartDescription.Title 屬性

定義

取得對應 WebPart 控制項的標題文字。

public:
 property System::String ^ Title { System::String ^ get(); };
public string Title { get; }
member this.Title : string
Public ReadOnly Property Title As String

屬性值

一個包含對應控制項標題的字串。 預設值是由 .NET Framework 提供的計算字串。

範例

以下程式碼範例展示了該 Title 屬性的程式化使用。 關於執行此程式碼範例所需的完整程式碼,請參閱課程概述主題中的 WebPartDescription 範例部分。

以下網頁方法中的程式碼Button1_Click示範如何利用該WebPartDescription方法取得目錄中的物件集合GetAvailableWebPartDescriptions,並透過迴圈物件WebPart來顯示目錄中每個WebPartDescription控制項的詳細資料。 請注意, Title 屬性值是在以下程式碼中取得的。

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 直接對應。 對應 WebPart 控制權對其 DisplayTitle 財產的控制權,即為該財產的 Title 價值;否則,產權即為計算價值。

此 Title 特性僅適用於頁面處於目錄顯示模式,且 WebPart 控制項在控制目錄中顯示時。 指派給 WebPart 控制項的標題會顯示在目錄中控制項旁邊。

適用於

另請參閱