Pages

Wednesday, November 4, 2009

Some Information on Web Parts and AJAX Web Parts

Web Parts


Web Part pages are pages that host Web Parts. Technically speaking a  Web Part is a class that inherits from the WebPart class defined in System.Web.UI.WebControls. ASP.NET 2.0 introduced  a Web Part infrastructure that requires exactly one WebPartManager control and one or more WebPartZone controls. The WebPartManager manages Web Part Instances and supports serialization of web part data so that it can be stored in the ASP.NET services database.  WSS 3.0 uses a control derived from WebPartManager called SPWebPartManager.

SPWebPartManager persists this data in the content database instead of the services database.  SPWebPartManager is already defined in the default.master page, so when you create a site page that links to this master page, this control is automatically added to your page.  Therefore you only need to add WebPartZones to create a Web Part.

Web Parts are the fundamental building block of SharePoint’s user interface.  They allow the SharePoint developer to achieve the goal of creating reusable components for business users which is, in many organizations, the primary task of a SharePoint developer.   Many Web Parts already exist  which may meet the needs of business users.

Web Parts make it possible for changes to customized site pages to be seen by all users on that site.  They also allow individual users to create personalized changes that only they can see. So Web Parts support both  customization and of personalization. Web Parts support customization of site pages but not application pages.   Customizing web parts does not require customization of the pages that host them.  All customization and personalization data are hosted inside the content database and is managed by the web part infrastructure.

To create a Web Part page, you must inherit from WebPartPage which is defined in Microsoft. SharePoint.dll, and you must add one or more WebPartZone controls.   One way to add a web part instance to a web part zone is to add an AllUsersWeb Part element to a feature.xml file.  A second method is to write code against the WSS object model  which may be required for more sophisticated processing.

Web Parts render inside what is know is chrome, the common user interface elements such as formatted title bar and borders around the web part’s body.  Chrome is rendered by the application framework (in this case WSS).

In SharePoint, Web Parts exist entirely within the content database and they are processed in safe mode. They should be as autonomous  as possible and should be compiled into a DLL.  They run under security settings that are defined in the web.config file and for this reason they should be deployed in solutions since Solution packages should correctly specify trust settings for deployment.

A Web Part Verb is an action that is rendered in the Web Part menu by the Web Part framework as a part of the chrome rendered around the control.  Web Part Connections are frequently used for master/detail records in Web Parts.

One useful building block for a Web Part is the SPGridView control which can be bound to SPDataSource to retrieve data from SharePoint lists.

 

AJAX Web Parts


AJAX Web Parts use several technologies to achieve an increased level of responsiveness once possible only in rich-client applications.  These technologies include:  object-oriented JavaScript, asynchronous data requests utilizing the XML HttpRequest object, XML data streams, Extensible Stylesheet Language Transforms (XSLT),  and dynamic manipulation of the HTML Document Object Model (DOM).

One of the main benefits is that smaller components are rendered in response to a user’s actions rather than rendering the entire page as a unit.   The AJAX approach includes a client runtime based on the ASP.NET AJAX library.  Instead of one large data stream being processed in the main request/response, individual components are responsible for their processing and can be individually refreshed based on user actions and events.   The user can continue working while individual AJAX components are processing.

Designing and building AJAX Web Parts is quite complex and this topic is definitely beyond the scope of this document.

Disha Shah

No comments:

Post a Comment