Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I am trying to show a alert box for an error.

Here is the part of the code:

XML
Catch ex As Exception
    ScriptManager.RegisterStartupScript(Me, Me.GetType(), "ExceptionMessage_AuditMain4", "<script type='text/JavaScript'>alert( '" + ex.Message + "');</script>", True)
Finally



But it doesn't display the alert message. The message is being called from a selected index change of a dropdownlist with autopostback enabled

Page has ajax update panels and I have step through the code to ensure the block is being tripped (executed).
Posted
Updated 28-Jan-12 21:52pm
v2

Using a partial page update, such with an UpdatePanel, you are not getting the full page life cycle and the script is not being injected into the response stream.

A more common approach is to pass the information back to the client via the javascript callback function and display any error messages there.
 
Share this answer
 
XML
Catch ex As Exception
dim msg as string=ex.message
    page.RegisterScriptblock( Me.GetType(), "alert ","alert("' & msg & '"), True)
Finally
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900