Condividi tramite


Sintassi dichiarativa per il controllo server Web EditorZone

[Questa documentazione ha solo scopo di anteprima ed è soggetta a modifiche nelle versioni successive. Gli argomenti vuoti sono inclusi come segnaposto.]

Funge da controllo primario nell'insieme di controlli Web part per l'hosting di controlli EditorPart in una pagina Web.

<asp:EditorZone
    AccessKey="string"
    ApplyVerb-Checked="True|False"
    ApplyVerb-Description="string"
    ApplyVerb-Enabled="True|False"
    ApplyVerb-ImageUrl="uri"
    ApplyVerb-Text="string"
    ApplyVerb-Visible="True|False"
    BackColor="color name|#dddddd"
    BackImageUrl="uri"
    BorderColor="color name|#dddddd"
    BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|Groove|Ridge|
                 Inset|Outset"
    BorderWidth="size"
    CancelVerb-Checked="True|False"
    CancelVerb-Description="string"
    CancelVerb-Enabled="True|False"
    CancelVerb-ImageUrl="uri"
    CancelVerb-Text="string"
    CancelVerb-Visible="True|False"
    CssClass="string"
    EmptyZoneText="string"
    Enabled="True|False"
    EnableTheming="True|False"
    EnableViewState="True|False"
    ErrorText="string"
    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"
    HeaderCloseVerb-Checked="True|False"
    HeaderCloseVerb-Description="string"
    HeaderCloseVerb-Enabled="True|False"
    HeaderCloseVerb-ImageUrl="uri"
    HeaderCloseVerb-Text="string"
    HeaderCloseVerb-Visible="True|False"
    HeaderText="string"
    Height="size"
    ID="string"
    InstructionText="string"
    OKVerb-Checked="True|False"
    OKVerb-Description="string"
    OKVerb-Enabled="True|False"
    OKVerb-ImageUrl="uri"
    OKVerb-Text="string"
    OKVerb-Visible="True|False"
    OnDataBinding="DataBinding event handler"
    OnDisposed="Disposed event handler"
    OnInit="Init event handler"
    OnLoad="Load event handler"
    OnPreRender="PreRender event handler"
    OnUnload="Unload event handler"
    Padding="integer"
    PartChromeType="Default|TitleAndBorder|None|TitleOnly|BorderOnly"
    runat="server"
    SkinID="string"
    Style="string"
    TabIndex="integer"
    ToolTip="string"
    VerbButtonType="Button|Image|Link"
    Width="size"
>
        <EmptyZoneTextStyle />
        <ErrorStyle />
        <FooterStyle
            BackColor="color name|#dddddd"
            BorderColor="color name|#dddddd"
            BorderStyle="NotSet|None|Dotted|Dashed|Solid|
                         Double|Groove|Ridge|Inset|Outset"
            BorderWidth="size"
            CssClass="string"
            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"
            Height="size"
            HorizontalAlign="NotSet|Left|Center|Right|Justify"
            OnDisposed="Disposed event handler"
            VerticalAlign="NotSet|Top|Middle|Bottom"
            Width="size"
            Wrap="True|False"
        />
        <HeaderStyle
            BackColor="color name|#dddddd"
            BorderColor="color name|#dddddd"
            BorderStyle="NotSet|None|Dotted|Dashed|Solid|
                         Double|Groove|Ridge|Inset|Outset"
            BorderWidth="size"
            CssClass="string"
            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"
            Height="size"
            HorizontalAlign="NotSet|Left|Center|Right|Justify"
            OnDisposed="Disposed event handler"
            VerticalAlign="NotSet|Top|Middle|Bottom"
            Width="size"
            Wrap="True|False"
        />
        <PartChromeStyle />
        <PartStyle
            BackColor="color name|#dddddd"
            BackImageUrl="uri"
            BorderColor="color name|#dddddd"
            BorderStyle="NotSet|None|Dotted|Dashed|Solid|
                         Double|Groove|Ridge|Inset|Outset"
            BorderWidth="size"
            CellPadding="integer"
            CellSpacing="integer"
            CssClass="string"
            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"
            GridLines="None|Horizontal|Vertical|Both"
            Height="size"
            HorizontalAlign="NotSet|Left|Center|Right|Justify"
            OnDisposed="Disposed event handler"
            Width="size"
        />
        <PartTitleStyle
            BackColor="color name|#dddddd"
            BorderColor="color name|#dddddd"
            BorderStyle="NotSet|None|Dotted|Dashed|Solid|
                         Double|Groove|Ridge|Inset|Outset"
            BorderWidth="size"
            CssClass="string"
            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"
            Height="size"
            HorizontalAlign="NotSet|Left|Center|Right|Justify"
            OnDisposed="Disposed event handler"
            VerticalAlign="NotSet|Top|Middle|Bottom"
            Width="size"
            Wrap="True|False"
        />
        <VerbStyle />
        <EditUIStyle />
        <HeaderCloseVerb
            Checked="True|False"
            Description="string"
            Enabled="True|False"
            ImageUrl="uri"
            Text="string"
            Visible="True|False"
        />
        <HeaderVerbStyle />
        <InstructionTextStyle />
        <LabelStyle />
        <ApplyVerb
            Checked="True|False"
            Description="string"
            Enabled="True|False"
            ImageUrl="uri"
            Text="string"
            Visible="True|False"
        />
        <CancelVerb
            Checked="True|False"
            Description="string"
            Enabled="True|False"
            ImageUrl="uri"
            Text="string"
            Visible="True|False"
        />
        <OKVerb
            Checked="True|False"
            Description="string"
            Enabled="True|False"
            ImageUrl="uri"
            Text="string"
            Visible="True|False"
        />
        <ZoneTemplate>
            <!-- child controls -->
        </ZoneTemplate>
</asp:EditorZone>

Note

Il controllo EditorZone è uno dei controlli fondamentali dell'insieme di controlli Web part. Una delle caratteristiche principali delle Web part è quella di offrire agli utenti finali la possibilità di modificare (o personalizzare) le pagine Web in base a specifiche preferenze e di salvare le impostazioni personalizzate per le future sessioni del browser. Un aspetto di tale funzionalità include la modifica di aspetto, layout, comportamento e altre proprietà dei controlli WebPart visibili. Diversi controlli dell'insieme di controlli Web part forniscono le funzionalità di modifica, tra cui il controllo EditorZone.

Per ulteriori informazioni sul controllo EditorZone e sui controlli Web part, vedere ASP.NET Web Parts Pages.

Esempio

Nell'esempio di codice riportato di seguito viene illustrato come utilizzare in modo dichiarativo il controllo EditorZone in uno scenario Web part con il controllo Calendar. La pagina Web consente a un utente di passare in modalità di modifica per modificare determinati aspetti del controllo Calendar. Il pulsante Toggle Scope consente di alternare l'ambito di personalizzazione della pagina dall'ambito user all'ambito condiviso o viceversa. I pulsanti Edit Mode e Browse Mode consentono di attivare la modalità di visualizzazione appropriata per la pagina. Nella sezione del tag <script> del file, due dei metodi di gestione degli eventi impiegano la proprietà Personalization per accedere ai membri utili dell'oggetto sottostante. In particolare questi metodi utilizzano il metodo ToggleScope e la proprietà Scope sull'oggetto cui è stato effettuato l'accesso tramite la proprietà Personalization.

Per poter eseguire l'esempio di codice, è inoltre necessario consentire a uno o più utenti di personalizzare le pagine nell'ambito condiviso. A tale scopo, aggiungere una voce nella sezione Elemento webParts (schema delle impostazioni ASP.NET) del file Web.config.

<%@ Page Language="VB" %>

<!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 Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        If ((mgr1.Personalization.Scope = PersonalizationScope.User) _
           And (mgr1.Personalization.CanEnterSharedScope)) Then
            mgr1.Personalization.ToggleScope()

        ElseIf (mgr1.Personalization.Scope = PersonalizationScope.Shared) Then
            mgr1.Personalization.ToggleScope()
        Else
            'If the user cannot enter shared scope you may want
            ' to notify them on the page.
        End If
    End Sub


    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        mgr1.DisplayMode = WebPartManager.EditDisplayMode
    End Sub    

    Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        mgr1.DisplayMode = WebPartManager.BrowseDisplayMode
    End Sub


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As CommandEventArgs)
        Label1.Text = "Scope is: " _
        + mgr1.Personalization.Scope.ToString()
    End Sub

</script>


<html xmlns="http://www.w3.org/1999/xhtml" >

<head id="head1" runat="server">
    <title>Web Parts Declarative Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <asp:LoginName id="LoginName1" runat="server" />
      <asp:WebPartManager id="mgr1" runat="server">
        <Personalization InitialScope="Shared" Enabled="True" />
      </asp:WebPartManager>
      <asp:WebPartZone id="WebPartZone1" runat="server">
        <ZoneTemplate>
          <asp:Calendar id="Calendar1" runat="server" />
        </ZoneTemplate>
        <CloseVerb Text="Close This Part" />
        <MinimizeVerb Text="Minimize This Part" />
        <EditVerb Text="Edit This Part" />
      </asp:WebPartZone>
      <asp:EditorZone id="EditorZone1" runat="server">
        <ZoneTemplate>
          <asp:LayoutEditorPart HorizontalAlign="Center" id="Layout1" runat="server" Title="My Custom Layout" />
          <asp:AppearanceEditorPart id="AppearanceEditorPart1" 
            runat="server" BackColor="LightGray" />
          <asp:BehaviorEditorPart id="BehaviorEditorPart1" 
            runat="server"  />
        </ZoneTemplate>
      </asp:EditorZone>
      <hr />
      <asp:Button id="Button1" runat="server" Text="Toggle Scope" OnClick="Button1_Click"  />
      <asp:Button id="Button2" runat="server" Text="Edit Mode" OnClick="Button2_Click" />
      <asp:Button id="Button3" runat="server" Text="Browse Mode" OnClick="Button3_Click" />
      <br />
      <asp:Label id="Label1" runat="server" Text="" />
    </div>
    </form>
</body>
</html>

<%@ Page Language="C#" %>

<!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 Button1_Click(object sender, EventArgs e)
  {
    if ((mgr1.Personalization.Scope == PersonalizationScope.User)
        && (mgr1.Personalization.CanEnterSharedScope))
    {
      mgr1.Personalization.ToggleScope();
    }
    else if (mgr1.Personalization.Scope ==
          PersonalizationScope.Shared)
    {
      mgr1.Personalization.ToggleScope();
    }
    else
    {
      // If the user cannot enter shared scope you may want
      // to notify them on the page.
    }
  }



  protected void Button2_Click(object sender, EventArgs e)
  {
    mgr1.DisplayMode = WebPartManager.EditDisplayMode;
  }


  protected void Button3_Click(object sender, EventArgs e)
  {
    mgr1.DisplayMode = WebPartManager.BrowseDisplayMode;
  }


  protected void Page_Load(object sender, EventArgs e)
  {
    Label1.Text = "Scope is: "
      + mgr1.Personalization.Scope.ToString();
  }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >

<head id="head1" runat="server">
    <title>Web Parts Declarative Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <asp:LoginName id="LoginName1" runat="server" />
      <asp:WebPartManager id="mgr1" runat="server">
        <Personalization InitialScope="Shared" Enabled="True" />
      </asp:WebPartManager>
      <asp:WebPartZone id="WebPartZone1" runat="server">
        <ZoneTemplate>
          <asp:Calendar id="Calendar1" runat="server" />
        </ZoneTemplate>
        <CloseVerb Text="Close This Part" />
        <MinimizeVerb Text="Minimize This Part" />
        <EditVerb Text="Edit This Part" />
      </asp:WebPartZone>
      <asp:EditorZone id="EditorZone1" runat="server">
        <ZoneTemplate>
          <asp:LayoutEditorPart HorizontalAlign="Center" id="Layout1" runat="server" Title="My Custom Layout" />
          <asp:AppearanceEditorPart id="AppearanceEditorPart1" 
            runat="server" BackColor="LightGray" />
          <asp:BehaviorEditorPart id="BehaviorEditorPart1" 
            runat="server"  />
        </ZoneTemplate>
      </asp:EditorZone>
      <hr />
      <asp:Button id="Button1" runat="server" Text="Toggle Scope" OnClick="Button1_Click"  />
      <asp:Button id="Button2" runat="server" Text="Edit Mode" OnClick="Button2_Click" />
      <asp:Button id="Button3" runat="server" Text="Browse Mode" OnClick="Button3_Click" />
      <br />
      <asp:Label id="Label1" runat="server" Text="" />
    </div>
    </form>
</body>
</html>

Vedere anche

Riferimenti

EditorZone

Altre risorse

ASP.NET Web Parts Pages