当前位置:首页 > 网络编程 > WEB编程 > ASP.net >  ASP.NET 2.0中使用webpart系列控件(4)

 ASP.NET 2.0中使用webpart系列控件(4)

点击次数:30 次 发布日期:2008-11-26 15:42:18 作者:源代码网
源代码网推荐      1、往窗体中拖拉一个catlogzone控件,如下图所视。
源代码网推荐  
源代码网推荐  
源代码网推荐  
源代码网推荐  2、往该catlogzone控件区域中,再拖放三个Webpart系列的控件,分别是DeclarativeCatalogPart, PageCatalogPart, and ImportCatalogPart,如下图所示。其中,DeclarativeCatalogPart控件的作用是,显示目前页面上有哪些可以用的webpart控件;PageCatalogPart的作用是,可以让用户通过勾选的方式,选定将哪些控件添加转移到其他webpart区域中去。ImportCatalogPart则可以通过外部磁盘文件的方式,加载其他做好了的webpart部件。
源代码网推荐  
源代码网推荐  
源代码网推荐  
源代码网推荐  3、在radiobutton区域中,修改以下代码,增添一个catalog display的显示模式:
源代码网推荐  
源代码网推荐  <ASP:RadioButtonList ID="rblMode" runat="server" AutoPostBack="True">
源代码网推荐  <asp:ListItem>Browse Display Mode</asp:ListItem>
源代码网推荐  <asp:ListItem>Design Display Mode</asp:ListItem>
源代码网推荐  <asp:ListItem>Catalog Display Mode</asp:ListItem>
源代码网推荐  </asp:RadioButtonList>
源代码网推荐  
源代码网推荐    然后,在code-behind的代码中,将代码修改为如下:
源代码网推荐  
源代码网推荐  Protected Sub rblMode_SelectedIndExchanged( _
源代码网推荐   ByVal sender As Object, _
源代码网推荐   ByVal e As System.EventArgs) _
源代码网推荐   Handles rblMode.SelectedIndexChanged
源代码网推荐    Select Case rblMode.SelectedIndex
源代码网推荐     Case 0 : WebPartManager1.DisplayMode = WebPartManager.BrowseDisplayMode
源代码网推荐     Case 1 : WebPartManager1.DisplayMode = WebPartManager.DesignDisplayMode
源代码网推荐     Case 2 : WebPartManager1.DisplayMode = WebPartManager.CatalogDisplayMode
源代码网推荐    End Select
源代码网推荐  End Sub
源代码网推荐  
源代码网推荐    4、在DeclarativeCatalogPart任务菜单上,点击右上角的智能感知按钮,然后选"edit templates"的链接,进入模版编辑状态,如下图:
源代码网推荐  
源代码网推荐  
源代码网推荐  
源代码网推荐  再往其中的webpartstemplate区域中拖拉一个google.ascx控件,如下图,这将允许用户在运行时,可以自由地往页面增加这样的google搜索控件。
源代码网推荐  
源代码网推荐  
源代码网推荐  
源代码网推荐   5、然后修改代码如下:
源代码网推荐  
源代码网推荐  <ZoneTemplate>
源代码网推荐  <asp:DeclarativeCatalogPart ID="DeclarativeCatalogPart1" runat="server">
源代码网推荐   <WebPartsTemplate>
源代码网推荐    <uc1:Google title="Google Search" ID="Google2" runat="server" />
源代码网推荐   </WebPartsTemplate>
源代码网推荐  </asp:DeclarativeCatalogPart>
源代码网推荐  
源代码网推荐    6、运行程序,可以看到,当选择catalog display mode时,会显示如下图所示的catalog zone,其中列出了当前可用的有哪些webpart控件,我们可以把这个google的控件加到其他的webpart区域,也可以尝试将已经存在的webpart控件关闭,然后在catalog zone区域中的控件列表中,把它们再加回到页面中去。
源代码网推荐  
源代码网推荐    做人要厚道,请注明转自酷网动力(www.ASPCOOL.COM)。
源代码网推荐


源代码网供稿.
网友评论 (0)
会员中心
网络编程
本站推荐
网络编程之精华