default heading
Get a FREE SQL & MySQL DB- Starting at $4.95/month
ASP.NET 4/3.5 SP1, Classic ASP, Silverlight 4, MVC 2.0, AJAX URL Rewrite Module 2.0, Windows 2008 + IIS 7 Hosting, MS SQL & MySQL included, Visual Studio 2010 and Much More. Click Here and Sign Up Now!
Google


 

Article Rating:  2.81

ASP.NET 2.0 (I) Enhancements to Existing Controls...

This article is the first in a series looking at ASP.NET 2.0. In this article we'll start with a consideration of the enhancements to existing controls that have been introduced...


By: Chris Sully Spacer Date: January 21, 2006Spacer Spacer Spacer Printer Friendly Version

Introduction

This article is the first in a series looking at ASP.NET 2.0 though it follows on from my earlier overview articles on the subject. In this article we’ll start with a consideration of the enhancements to existing controls that have been introduced. Many controls have gained new properties to extend the functionality they offer, as well as increasing their consistency with the new controls in ASP.NET 2.0. For example the Table and DataGrid controls now automatically support the details view on small-screen and mobile devices. Many controls have also been extended to ensure they are more usable and accessible. We'll start with an overview of the categories of control improvement before looking at particular controls in more detail.

Note that the information presented is based on the Beta product so minor changes may have been introduced in the final product release.

Summary of Control Improvements

Accessibility

Several new properties are added to improve the support for producing accessible web sites:

  • AccessibleHeaderText: allows specification of explanatory text for column headers for tabular data. Applies to controls that generate columns or rows in a GridView and DetailsView control.
  • AssociatedHeaderCellID: forces a control that displays a table to add the scope attribute to the header cells. Applies to TableCell control.
  • DescriptionURL: allows direction to more details regarding an image. Applies to Image control.
  • Caption and CaptionAlign: display a caption that describes a table. Applies to Calendar, DetailsView, FormView, GridView, Table, DataList and DataGrid controls.
  • GenerateEmptyAlternateText: instructs a control to do just that – add alt="" to the element thus indicating that the corresponding image contains no meaningful content. Applies to Image, ImageButton and ImageMap controls.
  • UseAccessibleHeader: adds the scope attribute to header cells. Applies to Calendar, GridView, DataList and DataGrid controls.

Data Source Control Integration

DataSourceID: all existing controls that support data binding now expose this property, as well as the new controls that do so.

Forms and Postback

Changes have been made to the postback architecture to support new features such as setting and maintaining the input focus and specifying the default button for each page. The three changes affect only the HtmlForm control that implements a server side form.

  • DefaultButton: indicates the button that will be selected when the user presses the return key.
  • DefaultFocus: indicates the control that will receive the focus on page load.
  • SubmitDisabledControls: a Boolean value that indicates whether disabled controls will have their values submitted when the form is submitted.

Input Controls

  • AssociatedControlID: allows linking a Label control to an interactive control such as a text box. It allows a hot key to be defined that moves the input focus directly to that control.
  • AutoCompleteType: specifies the field of a user’s vcard that should be used to automatically populate a textbox control.
  • InputAttributes and LabelAttributes: used with a CheckBox control to access the individual elements generated by a CheckBox control allowing attributes to configured.
  • PostBackURL: used with the Button controls to force the page to be posted to a different URL.
  • UseSubmitBehavior: used with Button controls to specify whether the form should be submitted using a clientside javsacript function (the default with a LinkButton) or the standard browser submit behaviour (the default for a Button and ImageButton).

List Controls

  • AppendDataBoundItems: tells the list control to add any items provided by a datasource to which it is bound to those already in the list, rather than replacing them (the default behaviour).
  • Enabled: indicates whether a ListItem should be displayed or not (it remains in the collection).

Mobile Device Support

  • The ability to display multiple views of a table and to navigate between them is provided for the existing DataGrid and Table controls, as well as the new GridView and DetailsView controls.
  • SoftKeyLabel: provides link shortcuts for devices such as mobiles. Applies to existing Button controls, the HyperLink control and the new PhoneCall control.
  • AllowPaginate: applies to the Panel control and specifies whether a control’s content can be broken into pages by a ContentPager control.

Site and Page Counter Integration

These new features add 9 properties for counting page views and click throughs and are supported by the controls that provide links (AdRotators, the Button controls, HyperLink and ImageMap).

Themes Integration

To support the new theming features two properties are added: EnableTheming and SkinID to most controls descended from System.web.ui.controls.

Validation

  • ValidationGroup: to support the new concept of validation groups which allow different sections of the page to be validated separately. It applies to all validation controls, all of the interactive form controls including list controls and button controls and the field controls of the GridVew and DetailsView controls.
  • SetFocusOnError: moves focus to a control that fails validation on page submission. Applies to all the validation controls.
  • CausesValidation: has been added to the base ListControl class so these can now circumvent page validation.
  • ValidateEmptyText: whether a control should treat an empty value as a validation failure. The default is to ignore empty values. Applies only to the CustomValidator control.

Individual Controls

Let's look in a little more detail at the specific controls that are new or that have changed significantly in 2.0.

AdRotator

Has been updated to include support for:

  • displaying adverts in pop up or pop under windows
  • data binding to non-XML datasources
  • using site counters that track impressions and click-throughs
  • sending adverts to mobile devices
  • displaying dynamic adverts when the page is cached

DataGrid

The DataGrid control in v2.0 use the same new device and control adapter architecture as the new GridView control to provide support for mobile devices. It automatically displays the contents in summary and details view, with links to select rows and to switch from on emdoe shown in summary view.

Literal

In 2.0 the Mode property has been added which allows you to control how the string assigned to the Text property is processed before being sent to the client. Why? So the page can tailor the output to suit different types of client device, e.g. if expecting WML rather than HTML. One of the three values of the LiteralMode enumeration which specifies valid values of the Mode property is Transform. When this is specified all markup not supported by the current client device is removed from output generated by the control.

Panel

The panel control has been enhanced in v2.0 to supporting presenting its content in a fixed size window with scroll bars as necessary. It has also been extended to work better with pagination through a ContentPager control, allowing output to be broken up into separate screens for client devices with smaller displays. This is specified via the AllowPaginate property.

There is also support for FieldSets. Since HTML 4.0 <fieldsets> and <legend> elements have been part of the standard. These are designed to be used to group together controls in web pages. The text value provided for the panels GroupingText property is used for the <legend> element content and this and the value of the Panel control (the value of the text property) are displayed within the <fieldset> element when the control is rendered.

Table

ASP.NET 2.0 automatically adapts generated output to different client types, as we'll see in further detail in subsequent articles. Support for this concept includes changes to the Table control to support 3 views of table data: a standard view for standard browsers and summary and details views for mobile phones (for example) which can be navigated between.

Summary

In this article we’ve looked at the changes to controls in ASP.NET 2.0 in overview. In the next article we’ll do the same for the brand new controls in ASP.NET 2.0.

References

ASP.NET v2.0 – the Beta Version
Homer et al.
Addison-Wesley

 
Please Rate This Article Poor           Excellent
 
 
 
 
 
   © Copyright 2002-2010 DotNetJohn.com LLC
Terms of Use Privacy Policy