Benefits Offered By ASP.Net Web Server Controls

ASP.NET offers two types of server control: HTML server controls and Web server controls. HTML server controls are simply regular web elements into which the runat=”server” attribute has been added and which have been assigned an ID. The runat=”server” attribute tells the ASP.NET engine that the control can respond to events and enables developers to create event handlers to control the behaviour of the controls.

ASP.NET offers two types of server control: HTML server controls and Web server controls. HTML server controls are simply regular web elements into which the runat=”server” attribute has been added and which have been assigned an ID. The runat=”server” attribute tells the ASP.NET engine that the control can respond to events and enables developers to create event handlers to control the behaviour of the controls.

Web server controls are more powerful than HTML controls because they are not linked to a specific HTML element and subject to its limitations. Some Web server controls are fairly simple but some of them are extremely complex. They offer black box functionality which would require fairly complex client-side and server-side coding to achieve if they did not exist. It is hardly surprising that server controls are the most frequently used component in ASP.NET.

When using Web server controls, developers are able to focus on the web page functionality and user-response that they require without having to worry about how this would be achieved using HTML elements. At runtime, the ASP.NET engine will generate the necessary HTML, CSS and JavaScript for each client browser.

The calendar control is one example of the advanced functionality offered by the ASP.NET Web server controls. The developer adds this to a web page as a single component and writes code to determine how it will respond to user interaction. At runtime, the necessary HTML markup is produced, saving the developer hours of coding and testing.

Another example of a sophisticated, time-saving Web server control is the FileUpload control. This allows you to add a browse and upload facility to any web page with very little coding. Similarly, the MultiView and View server controls are used in conjunction to control the visibility of different parts of a page. Each view contains different content and the end user is able to move through the views in the sequence specified by the developer.

Wizards are a very familiar feature in software programs and ASP.NET offers a Web server control that allows you to add this same functionality to a web page. The Wizard server control enables you to set up a series of steps which will be presented to your user in the order you specify. It is ideal for building forms where information is gathered in a series of steps rather than overwhelming the user with one single, huge form. The Wizard control is similar to the MultiView and View controls but offers a far greater degree of customization.

You can get up to date information on ASP.NET training courses, visit Macresource Computer Training, an independent computer training company offering ASP.NET Classes in London and throughout the UK.

The ASP.NET Master And Content Pages Model

ASP.NET master pages are powerful template pages containing information that is common to all pages in a site or all pages in one section of a site such as corporate logo, company information, headers, footers and navigation links. Content pages can then be created which are based on the master page(s). Master pages use the file extension “.master” which is automatically protected by the server and cannot therefore be downloaded by clients.

ASP.NET master pages are powerful template pages containing information that is common to all pages in a site or all pages in one section of a site such as corporate logo, company information, headers, footers and navigation links. Content pages can then be created which are based on the master page(s). Master pages use the file extension “.master” which is automatically protected by the server and cannot therefore be downloaded by clients.

The content pages consist of a reference to the appropriate master page together with the main page content and they use the regular ASP.NET file extension: “.aspx”. When the client requests a content page, the master and content pages are combined on the server and the resulting page sent back to the client.

An ASP.NET master page consist of locked areas, which can only be edited from the master and content areas, which can be filled with unique content each time a content page is created. You can create as many content areas as you need, though the default of one in the head area and one in the body is usually enough.

To create a master page in Visual Studio or Visual Web Developer, choose Add New Item from the Website menu and click on the Master Page icon. As with regular ASP.NET pages, you can choose the coding language and specify whether code will be placed in an external file or embedded in the page itself. To create a content page, choose Add New Item from the Website menu, click on the Web Form icon and activate the option “Select Master Page”. When you click the Add button, a second dialog will appear allowing you to choose a master page.

Master and content pages are great to work with from the developer’s point of view: they offer a great way of controlling the structure and layout of all the pages in a site. In addition, when working on content pages in Visual Studio or Visual Web Developer, the master page elements are displayed in preview mode, so the developer can always see what the final, composite page will look like to the end user. Naturally, however, the master page items cannot be edited from the content page.

Some of you may be tempted to make a comparison between Dreamweaver templates and ASP.NET master pages. However, ASP.NET master pages are much more powerful. In Dreamweaver, all of the template markup has to be copied into each page based on a template. If the template is altered, each page based on the template has to be updated and then uploaded to the server. With ASP.NET master pages, the master page elements are automatically combined with the content page element at runtime by the ASP.NET engine. So when a master page is altered, there is no need to manually update the content pages.

You can find out more about ASP.NET training courses, visit Macresource Computer Training, an independent computer training company offering ASP.NET training courses at their central London training centre.