PropertyGridEditorPart.Title 属性

定义

获取或设置编辑器控件的标题。

public:
 virtual property System::String ^ Title { System::String ^ get(); void set(System::String ^ value); };
public override string Title { get; set; }
member this.Title : string with get, set
Public Overrides Property Title As String

属性值

String

用作控件标题的字符串。 默认值是 Web 部件控件集提供的、计算出的控件名称。

示例

此代码示例演示如何使用 Title 控件的属性 PropertyGridEditorPart 。 有关运行示例所需的完整代码,请参阅类概述主题的示例 PropertyGridEditorPart 部分。

下面的代码示例演示如何在网页上以声明方式在控件上 PropertyGridEditorPart 设置标题。

<asp:EditorZone ID="EditorZone1" runat="server">
  <ZoneTemplate>
    <asp:PropertyGridEditorPart ID="PropertyGridEditorPart1" 
      runat="server" 
      Title="Edit Custom Properties"
      OnPreRender="PropertyGridEditorPart1_PreRender" 
      OnInit="PropertyGridEditorPart1_Init" />   
  </ZoneTemplate>
</asp:EditorZone>
<asp:EditorZone ID="EditorZone1" runat="server">
  <ZoneTemplate>
    <asp:PropertyGridEditorPart ID="PropertyGridEditorPart1" 
      runat="server" 
      Title="Edit Custom Properties"
      OnPreRender="PropertyGridEditorPart1_PreRender" 
      OnInit="PropertyGridEditorPart1_Init" />   
  </ZoneTemplate>
</asp:EditorZone>

代码示例的下一部分演示如何以编程方式设置属性的值 Title 。 为了持久保存以编程方式分配的值,将使用一 editControlTitle 个名为静态变量的静态变量,并且每次初始化控件时都会向 Title 该属性赋值,以便在回发事件之间保留该值。

private static String editControlTitle;

protected void Button1_Click(object sender, EventArgs e)
{
  editControlTitle = Server.HtmlEncode(TextBox1.Text);
  PropertyGridEditorPart1.Title = editControlTitle;
}

protected void PropertyGridEditorPart1_Init(object sender, EventArgs e)
{
  if (editControlTitle != null)
    PropertyGridEditorPart1.Title = editControlTitle;
}  
Shared editControlTitle As String

Protected Sub Button1_Click(ByVal sender As Object, _
  ByVal e As System.EventArgs)
  editControlTitle = Server.HtmlEncode(TextBox1.Text)
  PropertyGridEditorPart1.Title = editControlTitle 
End Sub

Protected Sub PropertyGridEditorPart1_Init(ByVal _
  sender As Object, ByVal e As System.EventArgs)
  If Not editControlTitle Is Nothing Then
    PropertyGridEditorPart1.Title = editControlTitle
  End If
End Sub

在浏览器中加载页面时,可以在 “显示模式”下拉列表控件中选择 “编辑模式”以切换到编辑模式。 可以单击“ 用户信息 WebPart ”控件标题栏中 (向下箭头) 的谓词菜单,然后单击“ 编辑 ”以开始编辑。 当编辑用户界面 (UI) 可见时,可以看到控件 PropertyGridEditorPart ,以及位于控件上方的按钮和文本框。 请注意,控件的标题是在网页的 PropertyGridEditorPart 声明性标记中为其分配的值。 如果在 “更新编辑器部件标题 ”按钮旁边的文本框中输入一些文本,然后单击该按钮,则将更新控件的标题。

注解

Title 控件在编辑模式下可见时,属性值将显示在控件的 PropertyGridEditorPart 标题栏中。 在页面中声明控件时,可以为该 Title 属性设置值。 如果未为游戏提供值,则会提供特定于区域性的默认值。

Title属性将替代基属性,以便如果没有提供标题值,则Web 部件控件集可以提供适合PropertyGridEditorPart控件的默认标题。

适用于

另请参阅