ASP.NET 2.0使用Web Part建立應用程式之一(共二)

來源:互聯網
上載者:User

 1.WebPartManager 控制項
Web Parts的總控中心,管理 Web Parts及地區的列表管理頁面狀態 (比如顯示狀態),當頁面狀態時發生改變時觸發事件,協助Web Parts間的通訊,管理個人化等.

<asp:WebPartManager ID="WebPartManager1" RunAt="server" />

2.WebPartZone 控制項
在 Web Parts頁面中定義地區,定義每個地區當中Web Part的預設顯示樣式及布局.<asp:WebPartZone ID="WeatherZone"
  DragHighlightColor="244,198,96" RunAt="server">
  <PartTitleStyle BackColor="#2254B1" ForeColor="White" />
  <PartStyle BorderColor="#81AAF2" BorderStyle="Solid" BorderWidth="1px" />
  <ZoneTemplate>
    <!-- Web Parts declared here -->
  </ZoneTemplate>
</asp:WebPartZone>

3.Web Part Chrome
標題框及Web Part的邊框,通過 WebPartZone 定義其外觀.
4.Web Parts
在 WebPartZone中定義的控制項;Web controls, user controls, custom controls
未實現IWebPart介面的控制項將封裝進GenericWebParts
增加以下屬性: Title, Description, etc.

<ZoneTemplate>
    <asp:Calendar Title="Calendar" ID="Calendar1" RunAt="server" />
    <user:Weather Title="Weather" ID="Weather1" RunAt="server" />
    <custom:Search Title="Search" ID="Search1" RunAt="server" />
  </ZoneTemplate>

5.WebPartManager.DisplayMode
設定或者擷取頁面的顯示模式BrowserDisplayMode         “正常的” 顯示模式,無法編輯(預設)
DesignDisplayMode            允許拖拽式布局編輯
EditDisplayMode                  允許編輯Web Part的外觀及行為
CatalogDisplayMode           允許將Web Part添加在另外的頁面上
ConnectDisplayMode         允許Web Parts之間進行通訊

6.DisplayMode 事件
WebPartManager.DisplayModeChanging 指示顯示模式是否要發生改變WebPartDisplayModeCancelEventArgs    獲得新的顯示模式並且允許控制者取消這種改變
WebPartManager.DisplayModeChanged  指示顯示模式是否已經發生改變
WebPartDisplayModeEventArgs               得到原來的顯示模式

7.其它的地區類型
WebPartZones 定義基本的頁面顯示內容,在任何時間均顯示,其它地區允許頁面可以被編輯,根據顯示模式有條件得進行顯示.CatalogZone            允許使用者在頁面上添加Web Part
EditorZone               允許使用者更改Web Part的屬性及布局
ConnectionsZone   允許使用者建立Web Part之間的通訊

8.CatalogZone 控制項
允許Web Part可以互動進行添加,包含一個或者多個 CatalogPart 控制項PageCatalogPart               顯示頁面上已經刪除的Web Part的列表
DeclarativeCatalogPart   顯示聲明在 <WebPartsTemplate>中的Web Part的列表
ImportCatalogPart           允許從 .WebPart檔案中匯入的Web Part

聲明 CatalogZone
<asp:CatalogZone ID="CatalogZone1" Runat="server">
  <ZoneTemplate>
    <asp:PageCatalogPart ID="PageCatalogPart1" Runat="server" />
    <asp:DeclarativeCatalogPart ID="DeclarativeCatalogPart1" Runat="server">
      <WebPartsTemplate>
        <!-- Declarative Web Parts go here -->
      </WebPartsTemplate>
    </asp:DeclarativeCatalogPart>
    <asp:ImportCatalogPart ID="ImportCatalogPart1" Runat="server" />
  </ZoneTemplate>
</asp:CatalogZone>

9.EditorZone控制項
允許互動對 Web parts變更,包含一個或者多個 EditorPart 控制項AppearanceEditorPart       提供修改標題及其它介面相關屬性的UI
BehaviorEditorPart            提供修改行為屬性的UI 
LayoutEditorPart               提供修改Web Part的顯示狀態,地區及地區索引的UI
PropertyGridEditorPart     提供修改定製屬性的UI

聲明 EditorZone
<asp:EditorZone ID="EditorZone1" Runat="server">
  <ZoneTemplate>
    <asp:AppearanceEditorPart ID="AppearanceEditorPart1" Runat="server" />
    <asp:BehaviorEditorPart ID="BehaviorEditorPart1" Runat="server" />
    <asp:LayoutEditorPart ID="LayoutEditorPart1" Runat="server" />
  </ZoneTemplate>
</asp:EditorZone>

10.PropertyGridEditorPart
允許修改自訂屬性的UI顯示標記為 [WebBrowsable]的屬性
string _stocks; // e.g., "MSFT,INTC,AMZN"

[WebBrowsable]
public string Stocks
{
    get { return _stocks; }
    set { _stocks =  value; }
}

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.