--------------------------------------------------------------------------------
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, here's 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 we've 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 it's title like the standard portal modules, add the PortalModuleTitle user control to your module. The PortalModuleTitle user control knows how to get the module's 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 module's title. EditText is the text to display in the link, and EditUrl is the path of the edit page, relative to the portal's 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>