Using Client Scripts with Button Controls

All three Button controls support an OnClientClick property. You can use this property to execute any client-side code that you need when a button is clicked. The page in Listing 2.18 illustrates how you can use the OnClientClick property to display a confirmation dialog box (see Figure 2.14).

Figure 2.14. Displaying a client-side confirmation dialog box.

image

Listing 2.18. ButtonOnClientClick.aspx

images

In Listing 2.18, the Button control includes an OnClientClick property, which executes a JavaScript script when ...

Get ASP.NET 4 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.