Using Client Script and DHTML


The client script and DHTML features of Web browsers allow controls to implement varying levels of client-side behavior. Web browsers such as Microsoft Internet Explorer provide a DOM that allows access to each tag in the page as an element. An element has properties, events, and methods that can be programmed against by using client-side script. Client script can be provided on a tag as the value of an attribute, embedded in the page within a <script> block, or placed in a separate file and included by using the src attribute of the <script> tag.

The simplest form of client-side behavior is to render simple script statements that are executed in response to events raised by various tag elements. The HoverLabel control we implemented in Chapter 8, "Rendering," rendered simple script statements to be executed in response to the onmouseover and onmouseout events.

When a control supports more complex client-side behavior, it typically packages its script into a set of script files and uses them as a script library by including references to the files with the <script src=""> syntax. In addition, the control can emit some script into the actual page that ties in the functionality of the referenced script files. The ASP.NET validation controls follow this model for implementing their client-side behavior.

Finally, a control might emit custom tags or elements into the page and provide the implementation of those tags as element behaviors in .htc files. Internet Explorer 5.5 and later versions support the ability to implement custom tags or elements that provide their own object model. This approach allows a server control to create a client-side programming model if needed. The Internet Explorer Web controls library uses this model in its implementation of controls such as TreeView and TabStrip .



Developing Microsoft ASP. NET Server Controls and Components
Developing Microsoft ASP.NET Server Controls and Components (Pro-Developer)
ISBN: 0735615829
EAN: 2147483647
Year: 2005
Pages: 183

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net