I use ScriptManager.RegisterStartupScrit from Page_Load and it works perfect.
When I move the same line to the Page_Unload event, it doesn’t work; the script is not registered.
Any suggestions??
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The Page_Unload event is called after the page is created and the html is outputted. The event is meant to be used to clean up any resources that must be freed by the page.
Why are you calling ScriptManager.RegisterStartupScript here?
EDIT:
See here for an overview over the page life cycle of an ASP.Net page. It should help you to determine where to place your code. Most likely the last time you can call ScriptManager.RegisterStartupScript is at the Page_PreRender event.