Muokkaa

Jaa


PropertyGridEditorPart.Title Property

Definition

Gets or sets a title for the editor control.

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

Property Value

A string that is used as the title of the control. The default value is a calculated control name supplied by the Web Parts control set.

Examples

This code example demonstrates how to use the Title property of a PropertyGridEditorPart control. For the full code required to run the example, see the Example section of the PropertyGridEditorPart class overview topic.

The following code example shows how to set the title on a PropertyGridEditorPart control declaratively in a Web page.

<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>

The next part of the code example shows how to set the value of the Title property programmatically. In order to persist the programmatically assigned value, a static variable named editControlTitle is used, and this value is assigned to the Title property each time the control is initialized, so that the value is persisted between postback events.

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

When you load the page in a browser, you can select Edit Mode in the Display Mode drop-down list control to switch to edit mode. You can click the verbs menu (the downward arrow) in the title bar of the User Information WebPart control, and click Edit to begin editing. When the editing user interface (UI) is visible, you can see the PropertyGridEditorPart control, and a button and text box positioned above it. Note that the title of the PropertyGridEditorPart control is the value assigned to it in the declarative markup of the Web page. If you enter some text in the text box next to the Update EditorPart Title button, and then click the button, the title for the control is updated.

Remarks

The Title property value is displayed in the title bar of a PropertyGridEditorPart control when the control is visible in edit mode. When the control is declared in a page, you can set a value for the Title attribute. If you do not supply a value for the title, a culture-specific default value is supplied.

The Title property overrides the base property so that, if no title value is supplied, a default title appropriate to a PropertyGridEditorPart control can be supplied by the Web Parts control set.

Applies to

See also