ASP.NET Web Server Controls That Use Client Script

Some ASP.NET server controls depend on client script for their functionality. In addition, some functionality of ASP.NET pages relies on client script. It is useful to know how ASP.NET controls and pages use client script so that you understand how ASP.NET Web pages might be affected by differences in how browsers support client script. For example, users sometimes disable script in a browser as a security measure. If they have done this, the functionality provided by client script is lost.

In addition, past accessibility guidelines require Web page functionality to be accessible when client script is turned off or not supported in a browser. If you want to conform to such guidelines, you might have to avoid controls that always use client script.

Browser Support for Client Script

The client script that ASP.NET generates automatically to support page or control functionality is compatible with all browsers that support ECMAScript (JScript or JavaScript) — that is, it does not depend on the advanced scripting capabilities of dynamic HTML (DHTML). An exception is the Web Parts control set. Web Parts controls require Microsoft Internet Explorer version 5.5 or a later version in order to implement the full capabilities of the controls. Some validation features can take advantage of DHTML if it is available in the browser, but DHMTL is not required.

Client Script Functionality That Is Used by All Controls

The following features that are supported by most Web server controls can cause them to use client script:

  • AutoPostBack behavior for non-button controls is implemented by using client script. Therefore, setting the AutoPostBack property of any Web server control to true causes the control to depend on client script.

  • Methods or properties that set focus on controls use client script. For example, the Control.Focus method and the Page.SetFocus method require client script.

Controls That Use Client Script

The following table lists controls and control members that take advantage of client script, and explains what functionality is provided by the client script. Controls that only use client script to support AutoPostBack behavior or to set focus are not included in this list.

Control

Client script functionality

Button

Setting the OnClientClick property causes the button to depend on client script.

Calendar

This control uses LinkButton controls to implement day, week, and month navigation.

If you use the Calendar control to display a single month without selection or navigation, the control does not require client script.

ChangePassword

This control generates validator controls for text boxes and LinkButton controls for submit and cancel buttons.

DataPager

If the QueryStringField property is not set and you are using NumericPagerField or NextPreviousPagerField objects, the DataPager control requires client script.

DetailsView

By default, this control uses LinkButton controls. To avoid the need for client script, create templates and add Button controls for these functions.

Client script can be used to paginate if the associated data source control supports this functionality.

If the EnablePagingCallbacks property is true, client script is used to manage the callback.

FormView

By default, the control uses LinkButton controls for functions such as switching to edit mode, paging, and so on. To avoid the need for client script, use the PagerTemplate property and add Button controls for these functions.

GridView

By default, the control uses LinkButton controls for functions such as switching to edit mode, paging, sorting, and so on. To avoid the need for client script, create templates and add Button controls for these functions.

If the EnableSortingAndPagingCallbacks property is true, client script is used to manage the callback.

HtmlButton

Client script is used to support postback events.

HtmlForm

This control is implicitly created by the <form runat=server> tag. The following properties require client script:

ImageButton

Client script is used to support postback events.

ImageMap

If you set the HotSpotMode property of the control or of individual hot spots to PostBack, the control requires client script to function.

LinkButton

Client script is used to support postback events.

LoginStatus

The control uses a LinkButton control to display the Logout link. To avoid the need for client script, create templates and add Button controls for these functions.

Menu

Client script is used to open and close menu items, display pop-out panels, and control the display when users position the mouse pointer over menu items.

Page

The MaintainScrollPositionOnPostback property requires client script.

PasswordRecovery

If the page's ClientTarget property is set to Downlevel, the control requires client script to function.

ScriptManager

This control manages client script files and loads the Microsoft Ajax Library.

Timer

Client script is used to perform postback events from the browser at defined intervals.

TreeView

Client script is used to open and close nodes. It is also used when the TreeView control is configured to populate nodes on demand.

Client script can be disabled for the TreeView control, in which case the selection behavior is performed in server code after a postback. However, the nodes themselves are rendered as links that use client script to perform a postback. Therefore, if the browser does not support client script, the TreeView control cannot perform a postback.

UpdatePanel

Client script is used for partial-page rendering (asynchronous postbacks) and is an integral part of the functionality of this control.

Validator controls:

By default, validator controls render client script to perform client-side validation to provide immediate validation feedback. However, because built-in validator controls (except the CustomValidator control) automatically perform a redundant validation check in server code, you can set the EnableClientScript property to false to avoid rendering client script for the validation controls.

Web Parts controls

Client script is used to support drag-and-drop behavior, to add Web Parts controls to zones, verbs, and to support import and export functionality.

Wizard, CreateUserWizard

The control renders LinkButton controls for navigation. To avoid the need for client script, create templates and add Button controls for these functions.

See Also

Concepts

ASP.NET Client Script

Client Script in ASP.NET Web Pages

Tab Order, Focus, and Access Keys in ASP.NET Web Server Controls

Accessibility in Visual Studio and ASP.NET

ASP.NET Controls and Accessibility