This chapter takes a more comprehensive look at how the client-side script used in the ComboBox control, described at the end of Chapter 5, works. It also discusses the three main requirements for producing interactive pages when using client-side script:
Access to all the elements on the page, with the ability to read and set the content of each one, show or hide it, and generally manipulate it
Access to a full range of keypress events, so that you can manage how a control behaves, depending on user interaction via the keyboard
The ability to statically and dynamically position elements outside the flow model, using fixed (absolute) coordinates that are relative to a container
Following this discussion, the chapter delves deeper into integrating client-side code with ASP.NET server-side code to produce useful controls and interactive pages. This chapter considers four topics:
Trapping an event that occurs on the client and popping up a confirmation dialog before carrying out the action on the server, by displaying a confirmation dialog before deleting a row in a DataGrid control.
Trapping the Return key to prevent a form from being submitted, or in fact trapping any keypress that might not be suitable for a control or an application you are building.
Handling individual keypress events, by implementing a MaskedEdit control.
Creating a button that can be clicked only once, to prevent the user from causing a second postback when nothing seems to be happening at the client.
So, as you've seen, getting exactly the performance, appearance, or usability you want is not always easy (or even possible!). However, you can create components and build reusable content that far exceeds the standard output that ASP.NET can provide on its own. Chapter 7 continues this theme by looking at some more user controls that combine with the features of ASP.NET to make building interactive pages easier.