UpdatePanels
and JavaScript
You must take special care when using JavaScript with UpdatePanel
controls. If you use the standard methods of the ClientScriptManager
class for working with JavaScript, they will fail when called during an asynchronous request.
For example, I often use the Page.ClientScript.RegisterStartupScript()
method from my server-side code to inject a JavaScript script into a page dynamically. The page in Listing 38.8 contains a Delete All Files button. When you click the button, and the FileHelper.DeleteAll()
method returns true
, a JavaScript alert box displays the message All Files Deleted Successfully! (see Figure 38.7).
Figure 38.7. Displaying a JavaScript alert.
Listing 38.8. ShowAlert.aspx
Unfortunately, the page ...
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.