Category : .Net Programming , Application Development , C# , General Articles , Internet News , IT Consulting , Offshore Development India , SharePoint Server , Software , Software Development , Software Development Company , Software Development India , Software Technology News , Uncategorized , Web application development , Web Site Development
This article discuss about the Web Parts, new feature introduced in ASP.NET 2.0. Web Parts are objects which the end user can open, close or move from one zone of the page to another. Web Parts allows for personalization of page content. They allows users to move or hide the Web Parts and add new Web Parts changing the page layout.
Web Parts Modes
Modes are very powerful in that they enable user to edit Web Parts, delete the Web Parts or customize Web Parts.
m a) Normal mode: End user cannot edit or move sections of page. Simple Browser mode.
m b) Edit Mode: End user can edit Web Parts on the page including Web Parts title, setting custom properties.
m c) Design Mode: End user can rearrange the order of the page Web Parts in a WebPartZone.
m d) Catalog Mode: End user enjoys the choice to add new Web Parts in any WebPartZone on the page.
Web Part Manager:-
Web Part Manager control is server control that completely manages the state of the zones . This control doesn’t have any visual interface,. You can have only one WebPartManager for each page that works with Portal Framework.
Web Part Zone:-
You can declare each web zone in one of two ways. You can use the <asp:WebPartZone> element directly in the code, or you can create the zones within the table by dragging and dropping Web Part Zone controls onto the design surface. You can place anything in zones including HTML elements, web server controls, user controls and custom controls. Any thing placed into WebPartZone can be treated as Web Part. Useful attributes of WebPartZone include LayoutOrientation attribute which controls the display of items either horizontally or vertically.
Catalog Zone:-(To add new Web Part)—-Catalog Mode
The ASP.NET 2.0 Portal Framework enables an end user to add Web Parts, but you must also provide the end user with a list of items he can add. It is designed to allow for categorization of the items that can be placed on the page. Catalog Zone is also a template control. The Catalog Zone control contains a title and checkbox list of items that can be selected. The Catalog Zone control also includes a drop down list of all available Web Part Zones on the page. From here, you can place the selected Web Parts into one of the Web Part Zones available from the list.
CatalogZone Contains CatalogPart controls like DeclarativeCatalogPart, PageCatalogPart, and ImportCatalogPart.
· PageCatalogPart: Provides a page catalog of Web Part controls that a user has closed on a Web Parts page, and that the user can add back to the page.
· DeclarativeCatalogPart: Enables developers to add a catalog of Web Part controls to a Web page so that users can choose whether to add them to a page.
· ImportCatalogPart: Imports Web Parts controls, so that the control can be added to a web page with pre-assigned settings.
Changing mode of page:-
You can use either WebPartManager class directly or through the use of WebPartManager server control, you can change the mode of page. Changing the mode allows the user to make changes to pages they are working with. All the changes (mode changes) are recorded to ASPNETDB.MDF database associated with app_data directory created exclusively for Web Parts. Using WebPartManager object, you can add new Web Parts to the page. It also enables end user to drag and drop elements around the page.
Moving Web Parts—Design Mode
We can also move WebParts from one zone to another zone. This is possible through Design mode. To move any control just hover mouse over title of the control and you can see crosshair mouse symbol. Click the left mouse button and hold the Web Part and drag it to any WebPartZone. While dragging, the control it becomes transparent and drops the control in WebPartZone.
Editing the Web Parts—Editing Mode
Another Web Part mode that allows end-user to edit the Web Parts is Edit mode. This mode enables users to modify the settings related to behavior, appearance and layout for a particular Web Part on the page. When the user change the mode to edit you can see Appearance Editor/Layout Editor appear in the EditorZone. Appearance section allows users to change title and how the title of Web Part appears. Layout section enables user to change the order in which Web Parts appears in a zone or move Web Parts from one zone to another. Behavior section enables site editors to change dynamics of how end user can modify Web Parts.
Connection Between Webparts:-
Web parts are also capable of exchanging data between them, using web part connections. Using connections, you can have one web part provide one or more property values that can be used by other web parts on the page.
A WebPart Connection is a mechanism for sharing or transferring data from one Web Part (called the provider) to another Web Part (called the consumer). it is the ability to expose an interface to a WebPart (Provider) that another WebPart (Consumer) can connect to and use it
· Connection types
– Control that provides data information
– Implements a provider connection point
– Defines a call back that returns an instance of the interface
– One provider connection point can connect to any number of consumer connection points of the same type
– Control that gets data
– Implements a consumer connection point
– Defines a call back that gets an instance of the interface return by provider
– One consumer connection point can connect to only one provider connection points of the same type
· Connection To establish a communication channel between provider and consumer WebParts so that they can exchange required information as defined in communication contract. A connection is establish between two connection points.The ConnectionPoint base class defines an object that is associated with a consumer or provider and contains the details necessary to exchange data. The ProviderConnectionPoint is associated with the provider, and the ConsumerConnectionPoint is associated with the consumer.
you must specify the following required attributes in addition to the id and runat attributes:
· ConsumerID – Indicates the ID of the consumer control in the connection.
· ConsumerConnectionPointID – Indicates the ID of a special callback method in the consumer used to establish the connection. This attribute is required only if the consumer has more than one connection point. For details on connection points, see ConnectionPoint.
· ProviderID – Indicates the ID of the provider control in the connection.
· ProviderConnectionPointID – Indicates the ID of a special callback method in the provider used to establish the connection. This attribute is required only if the provider has more than one connection point.