Monday, 18 May 2015

ASP Net Web Parts



ASP.NET Web Parts controls are an integrated set of controls for creating Web sites that enable end users to modify the content, appearance, and behavior of Web pages directly in a browser.



When users modify pages and controls, the settings can be saved to retain a user's personal preferences across future browser sessions, a feature called personalization.


There are many scenarios in our application where we want to either collect/present groups of information to the user. We would like to have the possibility for the user to selectively view any group of information. The user may also have an option of not viewing any group at all. The iGoogle interface is an excellent example of web parts in action. The user can choose to add some information on the page and he can even decide the appearance and location of that web part.

In ASP.NET terminology, Web parts are components that have some predefined functionality and they can be embedded in any web page. User can change the appearance and data related parameters of all web parts independently.
  • Web Parts facilitate personalization of page content. They let the users to move or hide the Web Parts and add new Web Parts changing the page layout.
  • Web Parts let the user to export or import Web Parts settings for use in other pages.
  • Web Parts can work in unison with ASP.NET role-based web access model. Each Web Part can be configured to be visible or hidden for any role.
  • Web Parts can share data with each other.

Before starting the code, let us look at few of the controls and terminologies that are useful in implementing web parts.
  1. WebPartsManager: This is a non visual control that has to be added on every page that needs to have web parts embedded in them. This control will facilitate the management of different web parts on a page.
  2. CatalogPart: This control is for managing the UI elements of all the web part available on a page. This control manages the web parts for the whole website.
  3. PageCatalogPart: This control provides the same functionality as the CatalogPart but it does it for an individual page rather than for the complete web site.
  4. EditorPart: This control lets the user customize the properties of web parts.
  5. WebPartZOne: This control is like a container for web parts. Any web part can be added to WebPartZoneonly.
  6. EditorZone: This control is like a container for EditorParts. Any EditorPart can be added onEditorZone only.
  7. CatalogZone: This control is like a container for CatalogParts. Any CatalogPart can be added onCatalogZone only.
WebPartManager is the most important of all the Web Part controls, responsible for managing and coordinating all controls inside WebPartZones. The Web Parts framework doesn't work without it, so every page that uses Web Parts must have an instance of WebPartManager declared, and it must be declared before other Web Parts controls. WebPartManager has no UI, so it's not visible on the page. It also exposes a very rich API for adding Web Parts to the page, closing Web Parts, connecting Web Parts, and more.

Modes:

Normal mode: The user cannot edit or move sections of page.
Edit Mode: End user can edit Web Parts on the page including Web Parts title, color or even setting custom properties.
Design Mode: End user can rearrange the order of the pages Web Parts in a WebPartZone.
Catalog Mode: End user can add new Web Parts or add deleted Web Parts in any WebPartZone on the page.

No comments:

Post a Comment