Advertisment

Web Parts in ASP.Net 2.0

author-image
CIOL Bureau
Updated On
New Update

Introduction

Advertisment

This new feature is known as Web Parts and is a very well known part of Share Point Portal Server and is also seen in many leading

Web sites like MSN, Yahoo, etc.

This feature is available through the link "My X" where X is the name of the site. When you click on this link you will be asked to sign in with your credentials depending on the site. For example you will have to sign in with Passport to MSN and sign in with Yahoo credentials to Yahoo.

The first thing you notice is that the page has been laid out in a certain fashion. The page has been divided into three tabs, one on the left, one on the right and the other one in the middle. This looks as seen below.

Advertisment
 
   
 
 

And you will see that certain widgets are placed in the home page and they all have different information and it is clear that the home page is a portal and it contains summary information from different sources.

And a new thing is that each widget has certain characteristics in common. They have a handle to grasp with the mouse and then drag and drop in any part of the

Web page between the other widgets. In addition each widget has a context menu and on clicking this reveals a drop down menu with the following details.

Advertisment

Figure 1. A view of "My MSN"

Change Detail



Refresh


Delete


Move


Close


Advertisment



Figure 2. The context menu for the widget.

Also at the top of the page there is a set of menus for working with the portal and it has features like

Advertisment

Add Content



Add Column


Add Page


Change Colors



Figure 3. The menu for customizing the lay out of the entire site.

Advertisment

Clearly this shows that the widget have a great deal of features to work with and they can be customized on a user-wise basis. Remember this

Website is seen only when you sign in and that means the Website is customized based on your login. Hence you will be able to add and remove controls, pages etc.

Well you must be wondering why were we talking about this portal so far and whether it did have anything common with ASP.NET 2.0. If you observe carefully, you will see that the features that we explored just now was quite impossible or a little hard to develop with ASP or ASP.NET 1.0/1.1. There was no magic control to develop that sophisticated control such as the widget with its own customized behavior and then to add content from various sources. Moreover the task of allowing the user to drag and drop the widget as he pleases on the page is also daunting and this is no piece of cake to develop.

Portals have been the bane of each and every user in a corporate environment and they are on the increase day by day. It is estimated that a few years from today, 98% of the

Websites will be portals all catering to the likes of each user allowing him/her to add widgets and customize the page.

Advertisment

ASP.NET 2.0 has great features to meet this demand of portals and one important feature is the inclusion of

Web Parts. Web Parts is another name for the widgets that we discussed just now.

What is ASP.NET Web Parts?

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

Web pages directly from a browser. The modifications can be applied to all users on the site or to individual users. 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. These

Web Parts capabilities mean that developers can empower end users to personalize a

Web application dynamically, without developer or administrator intervention.

Web Parts also have a great benefit for developers and they can give end users the following capabilities:



  • Personalize page content.
  • Users can add new Web Parts controls to a page, remove them, hide them, or minimize them like ordinary windows.



  • Personalize page layout.
  • Users can drag a Web Parts control to a different zone on a page, or change its appearance, properties, and behavior.



  • Export and import controls.
  • Users can import or export Web Parts control settings for use in other pages or sites, retaining the properties, appearance, and even the data in the controls. This reduces data entry and configuration demands on end users.



  • Create connections.
  • Users can establish connections between controls so that, for example, a chart control could display a graph for the data in a stock ticker control. Users could personalize not only the connection itself, but the appearance and details of how the chart control displays the data.



  • Manage and personalize site-level settings.
  • Authorized users can configure site-level settings, determine who can access a site or page, set role-based access to controls, and so on. For example, a user in an administrative role could set a

    Web Parts control to be shared by all users, and prevent users who are not administrators from personalizing the shared control.

Developer Scenarios for Using Web Parts





Let us see how the developer will work with Web Parts in ASP.NET 2.0. There are three ways of using

Web parts. They are

  • Creating pages that use Web Parts controls.
  • Creating individual Web Parts controls.
  • Creating complete personalizable Web applications, such as a portal.
  • Page Development



Page developers can use visual design tools such as Microsoft Visual Studio .NET to create pages that use

Web Parts. One advantage in using a tool such as Visual Studio is that the Web Parts control set provides features for drag-and-drop creation and configuration of

Web Parts controls in a visual designer. For example, the developer can use the designer to drag a

Web Parts zone, or a catalog, or a connection onto the design surface, and then configure the control right in the designer using the UI provided by the

Web Parts control set. This can speed development of Web Parts applications and reduce the amount of code that has to be written.





Control Development

Developers can use any existing ASP.NET control as a Web Parts control, including standard

Web server controls, custom server controls, and user controls. For maximum programmatic control of your environment, it is also possible to create custom

Web Parts controls that is derived from the WebPart class. For individual Web Parts control development, the developer will either create a user control and use it as a

Web Parts control, or develop a custom Web Parts control.

As an example of developing a custom Web Parts control, a developer might create a control to provide any of the features provided by other ASP.NET server controls that might be useful to build as a personalizable

Web Parts control such as calendars, lists, financial information, news, calculators, rich text controls for updating content, editable grids that connect to databases, charts that dynamically update their displays, weather and travel information.

Web Application Development





Developing fully integrated and personalizable Web applications--such as a portal-- involves the most comprehensive use of

Web Parts. Developers can develop a Web site that allows extensive user personalization of the UI and content--with features similar to My MSN. Or developers can even develop a packaged application that can be shipped and used by companies or fee-based ISP's that provide portal hosting services.

In a Web application scenario, developers can build a complete solution for end users to manage and personalize the application. This could include a set of

Web Parts controls that provide the desired features for the site, a consistent set of themes and styles that allow end users to personalize the UI in a consistent way, catalogs of

Web Parts controls from which users can select the ones they want to appear on a page, authentication services, and role-based management (for example, allowing administrative users to personalize

Web Parts controls and site settings for all users).

For each part of your application, users can extend the Web Parts control set as needed to provide greater control over the environment. For example, besides authoring custom

Web Parts controls for the primary UI of your pages, users can also develop a custom

Web Parts catalog that is consistent with the look and feel of your application. This gives users more flexibility to choose how controls are added to a page.

In the next section, we will explore this new feature and see how ASP.NET 2.0 allows to use the

Web Part control to provide rich functionality to the Web sites.






Disclaimer

"Since this article was written when the technology .NET 2.0 is still in development, there is no guarantee that the features explained will be there in the final version and is subject to change. This article should be taken only for getting a general idea of what is going to be available in .NET 2.0 and not the actual features that will be a part of the final release of .NET 2.0"



tech-news