Compartilhar via


PropertyGridEditorPart Web Server Control Declarative Syntax 

Provides an editor control that enables end users to edit custom properties on an associated WebPart or server control. This class cannot be inherited.

<asp:PropertyGridEditorPart
    AccessKey="string"
    BackColor="color name|#dddddd"
    BackImageUrl="uri"
    BorderColor="color name|#dddddd"
    BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|Groove|Ridge|
                 Inset|Outset"
    BorderWidth="size"
    ChromeState="Normal|Minimized"
    ChromeType="Default|TitleAndBorder|None|TitleOnly|BorderOnly"
    CssClass="string"
    DefaultButton="string"
    Description="string"
    Direction="NotSet|LeftToRight|RightToLeft"
    Enabled="True|False"
    EnableTheming="True|False"
    EnableViewState="True|False"
    Font-Bold="True|False"
    Font-Italic="True|False"
    Font-Names="string"
    Font-Overline="True|False"
    Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|Medium|
               Large|X-Large|XX-Large"
        Font-Strikeout="True|False"
    Font-Underline="True|False"
    ForeColor="color name|#dddddd"
    GroupingText="string"
    Height="size"
    HorizontalAlign="NotSet|Left|Center|Right|Justify"
    ID="string"
    OnDataBinding="DataBinding event handler"
    OnDisposed="Disposed event handler"
    OnInit="Init event handler"
    OnLoad="Load event handler"
    OnPreRender="PreRender event handler"
    OnUnload="Unload event handler"
    runat="server"
    ScrollBars="None|Horizontal|Vertical|Both|Auto"
    SkinID="string"
    Style="string"
    TabIndex="integer"
    Title="string"
    ToolTip="string"
    Visible="True|False"
    Width="size"
    Wrap="True|False"
/>

Remarks

The PropertyGridEditorPart provides a generic user interface (UI) that enables users to edit custom properties on WebPart and server controls that are placed in WebPartZoneBase zones. In contrast, the other EditorPart controls, such as the AppearanceEditorPart and BehaviorEditorPart controls, edit only existing, UI-oriented properties from the WebPart class.

For more information on the PropertyGridEditorPart and Web Parts controls, see ASP.NET Web Parts Pages.

Example

The following code example demonstrates how to use a PropertyGridEditorPart control. The Web page contains a declarative reference to an EditorZone control, with a child zonetemplate element that contains a declarative reference to a PropertyGridEditorPart control.

For the definitions of the user control and the custom control that is referenced in the @ Register, see "Example" in the class overview for PropertyGridEditorPart.

<%@ page language="VB" %>
<%@ register TagPrefix="uc1" 
  TagName="DisplayModeMenuVB" 
  Src="DisplayModeMenuVB.ascx" %>
<%@ register tagprefix="aspSample" 
  Namespace="Samples.AspNet.VB.Controls" 
  Assembly="UserInfoWebPartVB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

  Protected Sub Page_Load(ByVal sender As Object, _
    ByVal e As System.EventArgs)
    Button1.Visible = False
    TextBox1.Visible = False
  End Sub

  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

  Protected Sub PropertyGridEditorPart1_PreRender(ByVal _
    sender As Object, ByVal e As System.EventArgs)
    Button1.Visible = True
    TextBox1.Visible = True
  End Sub

</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head id="Head1" runat="server">
    <title>
      User Information WebPart with EditorPart
    </title>
  </head>
  <body>
    <form id="form1" runat="server">
      <asp:webpartmanager id="WebPartManager1" runat="server"  />
      <uc1:DisplayModeMenuVB ID="DisplayModeMenu1" runat="server" />
      <asp:webpartzone id="zone1" runat="server" >
        <PartTitleStyle BorderWidth="1" 
          Font-Names="Verdana, Arial"
          Font-Size="110%"
          BackColor="LightBlue" />
        <zonetemplate>
          <aspSample:UserInfoWebPart 
            runat="server"   
            id="userinfo" 
            title = "User Information WebPart"
            BackColor="Beige" />          
        </zonetemplate>
      </asp:webpartzone> 
      <div>
      <hr />
      <asp:Button ID="Button1" runat="server" 
        Text="Update EditorPart Title" 
        OnClick="Button1_Click" />
      <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
      </div>
      <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>
    </form>
  </body>
</html>
<%@ page language="c#" %>
<%@ register TagPrefix="uc1" 
  TagName="DisplayModeMenuCS" 
  Src="DisplayModeMenuCS.ascx" %>
<%@ register tagprefix="aspSample" 
  Namespace="Samples.AspNet.CS.Controls" 
  Assembly="UserInfoWebPartCS" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
  
  protected void Page_Load(object sender, EventArgs e)
  {
    Button1.Visible = false;
    TextBox1.Visible = false;
  }

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

  protected void PropertyGridEditorPart1_PreRender(object sender,
    EventArgs e)
  {
    Button1.Visible = true;
    TextBox1.Visible = true;
  }

</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>
      User Information WebPart with EditorPart
    </title>
  </head>
  <body>
    <form id="form1" runat="server">
      <asp:webpartmanager id="WebPartManager1" runat="server"  />
      <uc1:DisplayModeMenuCS ID="DisplayModeMenu1" runat="server" />
      <asp:webpartzone id="zone1" runat="server" >
        <PartTitleStyle BorderWidth="1" 
          Font-Names="Verdana, Arial"
          Font-Size="110%"
          BackColor="LightBlue" />
        <zonetemplate>
          <aspSample:UserInfoWebPart 
            runat="server"   
            id="userinfo" 
            title = "User Information WebPart"
            BackColor="Beige" />          
        </zonetemplate>
      </asp:webpartzone> 
      <div>
      <hr />
      <asp:Button ID="Button1" runat="server" 
        Text="Update EditorPart Title" 
        OnClick="Button1_Click" />
      <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
      </div>
      <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>
    </form>
  </body>
</html>

See Also

Reference

PropertyGridEditorPart

Other Resources

ASP.NET Web Parts Pages