Go Back   Wiki NewForum | Latest Entertainment News > Career Forum & Tips > Tech Forum & Tutorial > ASP.NET Forum & Tutorial


Web Parts Framework


Reply
Views: 2280  
Thread Tools Rate Thread
  #1  
Old 05-30-2009, 09:39 AM
bholus7
Guest
 
Posts: n/a
Default Web Parts Framework

Web Parts Framework

There are many times when you would want to allow the users of your web site to be able to customize the content by selecting, removing, and rearranging the contents in the web page.

Traditionally, implementing this capability required a lot of custom code, or you had to depend on third-party products to accomplish this. To address this shortcoming, ASP.NET 2.0 ships with a Web Parts Framework that provides the infrastructure and the building blocks required for creating modular web pages that can be easily customized by the users.

You can use Web Parts to create portal pages that aggregate different types of content, such as static text, links, and content that can change at runtime.

It is also possible for the users to change the layout of the Web Parts by dragging and dropping them from one place to another, providing a rich user experience.

By taking advantage of Web Parts, you, as a developer, can empower your users with the ability to perform the following operations.

* Users can personalize page content.

* Users can personalize the page layout by allowing the users to drag Web Parts from one zone to another zone, or change its appearance, look and feel, and so on.

* Users can also export and import Web Part controls so the Web Parts can be effectively shared among other sites.

* Users can create connections between two Web Parts by establishing communication between Web Part controls.

As a developer, you will typically work with Web Parts in one of the three ways: creating pages that use Web Parts controls, creating individual Web Parts controls, or creating complete personalizable web portals. You can create two kinds of Web Parts in ASP.NET 2.0:

* Custom Web Part: Those Web Part controls that derive from the System.Web.UI .WebControls.WebParts.WebPart class.

* Generic Web Part: A custom control that does not inherit from the WebPart class and is still used as a Web Part is called GenericWebPart. For example, if you place a TextBox control inside a WebPartZone control (a zone on the page that hosts the Web Parts control), the TextBox control will be wrapped to a GenericWebPart class.


This section provides you with a simple generic Web Part creation example followed by a code examination. Listing 1-3 shows the code required to implement the Web Part.

Reply With Quote
  #2  
Old 05-30-2009, 09:42 AM
bholus7
Guest
 
Posts: n/a
Default Listing 1-3: Creating a Simple Generic Web Part

Listing 1-3: Creating a Simple Generic Web Part


<%@ Page Language=”C#” %>
http://www.w3.org/1999/xhtml” >

Example of a GenericWebPart













GenericWebPart that uses a label control to generate the contents of the Web Part











To start with, you declare a WebPartManager control. The WebPartManager control is a must for any ASP.NET page that utilizes Web Parts.

This control must be the first element in an ASP.NET web form, above all other Web Parts, zones, or any other custom or specialized Web Part controls.

The WebPartManager has no visual element associated with it; however, it is crucial because of the required plumbing it provides for managing the interactions between Web Parts.

Then the code declares a WebPartZone control, which in turn includes a Label control that consists of all the HTML elements that make up the display of the Web Part.

The WebPartZone control is the one that provides overall layout for the Web Part controls that compose the main UI of a page.

Before navigating to the page using the browser, enable Windows Authentication for the web site through IIS Manager and ensure that SQL Server 2005 Express is installed with Windows authentication enabled.

Now run the page, and you will see the output shown in Figure 1-2.

ASP.NET 2.0 Web Parts Framework

Reply With Quote
  #3  
Old 05-30-2009, 09:49 AM
bholus7
Guest
 
Posts: n/a
Default Personalization Framework

Personalization Framework

There are times when you want to store and present information that is unique to a specific user. For instance, when a user visits your site, you can collect information from the user about his preferences, such as color scheme, styles, and so forth.



Once you have that information, you can use it to present the user with a personalized version of your web application. To implement this with ASP.NET 1.x, you had to go through the following steps.
  1. Store user information with a unique user identifier, used to identify the user when he visits again.
  2. Fetch the user information as needed.
  3. Finally, present the user with the personalized content.
Now with the introduction of ASP.NET 2.0 personalization, all of the above complexities are handled by the personalization framework itself. In ASP.NET personalization, information about a specific user is stored in a persistent format.



Also, ASP.NET personalization allows you to easily manage user information without requiring you to create and maintain your own database. In addition, the personalization system makes the user information available using a consistent, easy-to-use, strongly typed API that you can access from anywhere in your application.


You can also store objects of any type in the personalization system, including user information, user preferences, or business information. The personalization system uses a generic storage system for storing the data and makes that data available to the users in a type-safe manner.



By default, ASP.NET 2.0 uses SQL Server as the storage mechanism.
Reply With Quote
Reply

New topics in ASP.NET Forum & Tutorial





Powered by vBulletin® Version 3.8.10
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
WikiNewForum)