ASP.NET Tutorial/WebPart/WebPartZone

Материал из .Net Framework эксперт
Перейти к: навигация, поиск

Creating multiple Web zones

<%@ Page Language="VB"%>
    
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Web Parts Example</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:WebPartManager ID="Webpartmanager1" runat="server">
        </asp:WebPartManager>
        <table>
            <tr>
                <td colspan="3">
                    <asp:WebPartZone ID="WebPartZone1" 
                                     runat="server"
                                     LayoutOrientation="Horizontal">
                        <ZoneTemplate>
                            <asp:Label ID="Label1" 
                                       runat="server" Text="Label"
                                       Title="Welcome to my web page!">
                                       Welcome to the page!
                            </asp:Label>
                        </ZoneTemplate>
                    </asp:WebPartZone>
                </td>
            </tr>
            <tr valign="top">
                <td>
                    <asp:WebPartZone ID="WebPartZone2" runat="server">
                        <ZoneTemplate>
                            <asp:Image ID="Image1" runat="server"
                             ImageUrl="~/Images/Kids.jpg" Width="150px"
                             Title="My Kids">
                            </asp:Image>
                        </ZoneTemplate>
                    </asp:WebPartZone>
                </td>
                <td>
                    <asp:WebPartZone ID="WebPartZone3" runat="server">
                        <ZoneTemplate>
                            <asp:Calendar ID="Calendar1" runat="server"
                             Title="Calendar">
                            </asp:Calendar>
                        </ZoneTemplate>
                    </asp:WebPartZone>
                </td>
            </tr>
        </table>        
    </form>
</body>
</html>


Graying out the Close link in a Web Part

<asp:WebPartZone ID="WebPartZone3" Runat="server">
      <CloseVerb Enabled="False" />
      <ZoneTemplate>
         <asp:Calendar ID="Calendar1" Runat="server">
         </asp:Calendar>
      </ZoneTemplate>
</asp:WebPartZone>


Removing the Close link in a Web Part

<asp:WebPartZone ID="WebPartZone3" Runat="server">
      <CloseVerb Visible="False" />
      <ZoneTemplate>
         <asp:Calendar ID="Calendar1" Runat="server">
         </asp:Calendar>
      </ZoneTemplate>
</asp:WebPartZone>


Turning off the zone modification capability

<asp:WebPartZone ID="WebPartZone1" 
                 runat="server" 
                 LayoutOrientation="Horizontal" 
                 AllowLayoutChange="false">
      <ZoneTemplate>
      <asp:Label ID="Label1" 
                 runat="server" 
                 Text="Label"
                 Title="Welcome to my web page!">
                 Welcome to the page!
      </asp:Label>
      </ZoneTemplate>
</asp:WebPartZone>


Using images for the Web Part verbs

<asp:WebPartZone ID="WebPartZone3" Runat="server">
      <CloseVerb ImageUrl="Images/CloseVerb.gif" />
      <MinimizeVerb ImageUrl="Images/MinimizeVerb.gif" />
      <ZoneTemplate>
         <asp:Calendar ID="Calendar1" Runat="server">
         </asp:Calendar>
      </ZoneTemplate>
</asp:WebPartZone>