Compartilhar via


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 your Web pages might be affected by differences in how browsers support client script.

Element List

The following table lists controls or control properties that take advantage of client script and what functionality is provided by client script.

Control Client script functionality

Page, HtmlForm, Panel

The following properties require client script:

LinkButton, ImageButton, and HtmlButton

NoteNote
This does not include either the Button Web server control or the HtmlInputButton and HtmlInputImage controls, which do not require client script.

Client script is used to support postback events.

Calendar

This control uses LinkButton controls to implement day, week, and month navigation; the LinkButton control uses client script for postback events. If you use the Calendar control simply to display a single month with no selection or navigation, the control does not require client script.

DetailsView

If the control includes buttons configured as LinkButton controls (for editing, paging, and so on), those functions require client script.

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.

GridView

If the control includes buttons configured as LinkButton controls (for editing, paging, and so on), those functions require client script.

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

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

Label

The AssociatedControlID property, in conjunction with the AccessKey property, generates client script to set the focus on the appropriate control in response to a keyboard shortcut. If these properties are not set, client script is not required for this control.

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.

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, so if the browser does not support client script, the TreeView cannot perform a postback.

Any Web server control with its AutoPostBack property set to true.

The AutoPostBack property behavior for non-button controls is implemented using client script.

Web Parts controls

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

Validator controls:

Client script is used to provide immediate validation feedback. If the client does not support script, validation will run on the server only.

Any methods or properties that set focus on controls, such as the Focus method on controls and the page's SetFocus method.

Client script is used to set focus on the specified control.

The client script required for these controls and members is automatically generated and sent as part of the page. It is compatible with all types of browsers that support ECMAScript (JScript, JavaScript) — that is, it does not depend on the advanced scripting capabilities of dynamic HTML (DHTML). An exception is the Web Parts control set, which requires Microsoft Internet Explorer version 5.5 or later to implement full capabilities.

NoteNote

Some validation features can take advantage of DHTML if it is available in the browser, but DHMTL is not required.

Users sometimes disable script in a browser as a security measure. If they have done so, the functionality provided by client script is lost. This disables some controls, such as the LinkButton control, entirely, and disables the functionality of the AutoPostBack property. Validation is only partially affected; validation is still performed on the server, but users do not get the immediacy and performance of client-side validation.

See Also

Concepts

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