Web Parts and Portal
P R E S E N T E R : M R . D O A N Q U A N G M I N H
Agenda
Introduction
ASP.NET 2.0 Portal Framework
Web Parts Control
Connecting Web Parts
Connecting Web Parts
Demo
Introduction
Portal
Is a website that provides a starting point or gateway to other
resources on the Internet or an intranet
Web Parts:
An extension of custom controls with the flexibility and user
An extension of custom controls with the flexibility and user
controls
Provide the foundation for both customization and
personalization
Connections between components
Personalization
Ability to customize the information that provide by portal
ASP.NET 2.0 Portal Framework
Web Parts
Are controls that display to end-user.
Allow to personalize.
Connections
Allow to communicate between each separate web part to
Allow to communicate between each separate web part to
share information
Web Part Manager
Monitoring the perform of all web parts
ASP.NET 2.0 Portal Framework
Editing
The area that contains the editor controls.
These controls include AppearanceEditor, LayoutEditor,
BehaviorEditor, and PropertyGridEditor
Catalog
Catalog
The place that show to end-user list web parts available which
they can add to their page.
The WebPartManager Control
Regulates operation of Web Parts
Maintains list of Web Parts and zones
Manages page state (for example, display mode) and fires
events when page state changes
Facilitates communication between Web Parts
Facilitates communication between Web Parts
Manages personalization
One and only one instance per page. No UI
<asp:WebPartManager ID="WebPartManager1“ runat="server" />
The WebPartZone Control
Defines zones on a Web Parts page
Defines default layout and appearance of Web Parts
within each zone
<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>
Web Parts
Controls defined in a WebPartZone
Web controls, user controls, custom controls
Controls that don't implement IWebPart are
internally wrapped in GenericWebParts
Adds properties: Title, Description, etc.
Adds properties: 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>
Display Mode
5 display mode of web part
BrowseDisplayMode: Standard view mode. No personalization
or editing.
DesignDisplayMode: Enables drag-and-drop layout
personalization or customization
personalization or customization
EditDisplayMode: Enables personalization or customization of
Web Part properties to change appearance and behavior.
Allows user to delete dynamically added Web Parts.
ConnectDisplayMode: Enables user to connect Web Parts at
run time
CatalogDisplayMode: Enables users to add Web Parts at run
time
Customization Controls
Edit Parts (EditDisplayMode):
PropertyGridEditorPart
AppearanceEditorPart
BehaviorEditorPart
LayoutEditorPart
LayoutEditorPart
Catalog Parts (CatalogDisplayMode):
PageCatalogPart – lists of closed Web Parts
DeclarativeCatalogPart – lists Web Parts that can be
added
Connecting Web Parts
Web Parts can communicate
Provider publishes interface
Consumer uses interface to retrieve data
WebPartManager manages connections
Retrieves interfaces from providers
Retrieves interfaces from providers
Provides interfaces to consumers
Connections can be static or dynamic
ConnectionsZone provides UI for latter
Connecting Web Parts
Connection Providers
Implements Method that returns interface
Method attributed [ConnectionProvider]
[
ConnectionProvider
("Zip Code", "
ZipCodeProvider
")]
[
ConnectionProvider
("Zip Code", "
ZipCodeProvider
")]
public IZipCode GetZipCodeInterface ()
{
return this; // Assumes control implements IZipCode
}
// IZipCode.GetZipCode implementation
public string GetZipCode ()
{
return _zip;
}
Connection Consumers
Implements Method that receives interface
Method attributed [ConnectionConsumer]
[
ConnectionConsumer
("Zip Code", "
ZipCodeConsumer
")]
[
ConnectionConsumer
("Zip Code", "
ZipCodeConsumer
")]
public void GetIZipCodeInterface (IZipCode provider)
{
string zip = provider.GetZipCode (); // Get zip from provider
}
Web Part Connections
1. WebPartManager calls
[ConnectionProvider]
method
2. WebPartManager
receives provider
interface in return
WebPartManager
3. WebPartManager calls
[ConnectionConsumer]
method, passing
interface to consumer
4. Consumer calls provider
using supplied interface
Provider
Consumer
44
Reference
www.asp.net
www.msdn.com
ASP.NET 2.0 Web Parts in Action
Some others resource on Internet
Some others resource on Internet