Pages

Thursday, November 22, 2007

WebParts in ASP.Net 2.0

Webparts are going to be the future of web based management systems. WebParts give us the option of dragging and dropping of objects on a page as well as, changing titles and border style properties of objects at runtime. Before the introduction of WebParts it was used to be a hectic task because we had to write a lot of Javascript and had to save the state of objects in a database.

There are two basic things in WebParts:
1.) WebPart manager
2.) WebPart zones

WebPartManager
The WebPartManager is the manager for all webparts. If webparts are used in web projects then WebPartManager is required. Usually you just drag and drop this into your webform and are ready to go.

WebPart Zones
There are four kinds of zones in webpart zones:

1.) WebPart Zone
2.) Editor Zone
3.) Catalog Zone
4.) Connection Zone

The webpart Zone is the basic unit for webparts. By placing different contents in a webpart zone we can allow a user to drag and drop contents on a page.
To use different zones add a dropdownlist to your webform and add the following items to it.
----Browse
----Display
----Edit
----Catalog
----Connect

Browse Mode
The Browse mode is the default mode of webparts. In Browse mode we can not drag and drop the webparts but we can see two options, minimize and close. Minimizing a webpart will still display it in minimized state. If you choose close then it can only be restored while being in catalog mode.

Design mode
In design mode we can drag drop objects between webparts.

Edit Mode
The edit mode is used to edit webparts at runtime. Editing a webpart is further divided into four types: Appearance, Behavior, Property and Layout.

Catalog mode
The Catalog mode gives us the option to add/remove webparts at runtime. For example if we have few modules like weather, news, shopping, horoscope etc. and want to give the user an option to show or hide these modules at runtime, we can accomplish this task using the catalog mode.

Connect mode
This mode allows webparts to communicate with each other. We can make static connections once (in our code) or we can allow users to create connecttions at runtime according to their needs. The Connection mode doesn’t mean mean that the webpart is connecting to a database rather means it is connected to other webparts. For example if a webpart contains a grid, used to display some records and we want to filter it on the users input, then we could use a textbox in another webpart, which would send the filter criteria text by using the connect mode.

For more information,check
http://dotnetslackers.com/articles/aspnet/UsingWebPartsInASPNet20.aspx

No comments: