欢迎光临
我们一直在努力

Creating Custom Portal Modules-.NET教程,Asp.Net开发

建站超值云服务器,限时71元/月

——————————————————————————–
a portal module combines some code and ui to present specific functionality to the user (for example, a threaded discussion) or render data, graphics and text, (for example, a "sales by region" report). in addition, a portal module needs to know how to interact with the portal framework to participate in the rendering, editing, caching and roles-based security services it provides.

portal modules are implemented as standard asp.net user controls. the logic required to enable the user control to work inside the portal framework is encapsulated in a special base class: aspnetportal.portalmodulecontrol. to create a custom portal module, simply make a user control that inherits from the aspnetportal.portalmodulecontrol class.

hello world

for example, heres a simple "hello world" portal module (helloworld.ascx).  
      <%@ control inherits="aspnetportal.portalmodulecontrol" %>

    hello world!
                

  using css styles in portal modules

the portal framework includes a stylesheet called portal.css that is applied to all tabs in the portal. you can use the styles defined in portal.css to make the appearance of your custom module consistent with the built-in modules. the most commonly used style is "normal", which is applied to most text rendered by modules. here weve updated helloworld.ascx to use a style.  
      <%@ control inherits="aspnetportal.portalmodulecontrol" %>

    <span class="normal">hello world!</span>
                

  adding a title to your module

when the portal administrator adds an instance of a module to the portal, she can give it a descriptive title. if you want your module to display its title like the standard portal modules, add the portalmoduletitle user control to your module. the portalmoduletitle user control knows how to get the modules title from the portal framework, and render it consistently with the rest of the portal.

      <%@ control inherits="aspnetportal.portalmodulecontrol" %>
    <%@ register tagprefix="portal" tagname="title" src="../../portalmoduletitle.ascx" %>

    <portal:title runat="server" />
    <span class="normal">hello world!</span>
                

  adding support for an edit page

if your module has an edit page, you can also use the portalmoduletitle to render the edit item link next to the modules title. edittext is the text to display in the link, and editurl is the path of the edit page, relative to the portals root directory.

      <%@ control inherits="aspnetportal.portalmodulecontrol" %>
    <%@ register tagprefix="portal" tagname="title" src="../../portalmoduletitle.ascx" %>

    <portal:title edittext="edit" editurl="portalmodules/helloworld/edithello.aspx" runat="server" />
    <span class="normal">hello world!</span>
                

  creating a module that uses data

many portal modules display data from a database or xml file as a part of their rendered output. to display data, you load and bind it just as you would for a regular asp.net user control. heres a typical example using the northwind sql database.

      <%@ control inherits="aspnetportal.portalmodulecontrol" %>
    <%@ import namespace="system.data" %>
    <%@ import namespace="system.data.sql" %>
    <%@ register tagprefix="portal" tagname="title" src="portalmoduletitle.ascx" %>

    <script language="vb" runat="server">

        sub page_load(sender as object, e as eventargs)

            dim connection as new sqlconnection("server=localhost;uid=sa;pwd=;database=northwind")
            dim command as new sqldatasetcommand("select top 10 productname,
                unitprice from products order by unitprice desc", connection)

            dim dataset as new dataset()
            command.filldataset(dataset, "products")

            grid1.datasource = dataset.tables(0).defaultview
            grid1.databind()

        end sub

    </script>

    <portal:title runat="server" />

    <asp:datagrid id=grid1
        autogeneratecolumns="false"
        cssclass="normal"
        showheader="false"
        borderwidth="0"
        runat="server">

        <property name="columns">
            <asp:boundcolumn datafield="productname" />
            <asp:boundcolumn datafield="unitprice" dataformatstring="{0:c}" />
        </property>

    </asp:datagrid>
                

  

adding a custom module to the admin tool
——————————————————————————–
to add a module to the admin tool, you simply create an entry for it in the <moduledefinitions> section of the portal.config file. (youll need to edit the file directly; theres is no support for modifying this part of the configuration file in the admin tool itself.)

for example:
        <moduledefinitions>
            <moduledefinition name="helloworld" src="portalmodules/helloworld/helloworld.ascx"/>
        </moduledefinitions>
                

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » Creating Custom Portal Modules-.NET教程,Asp.Net开发
分享到: 更多 (0)