RegisterStartupScript from ASP.NET Content Page
Posted on 2011-02-23
I have been re-writing a web application which used frames to use a master/content page architecture and have run into an odd problem.
Within a content page I have a form which the user complets and then clicks a 'Save' button. This posts back to the server where some additional validation is performed and depending on the results I want to display a message to the user.
I have now simplified this within my button onclick handler to :-
const string alertScript = "alertSaveChanges";
if (!ClientScript.IsStartupScriptRegistered(this.GetType(), alertScript))
ClientScript.RegisterStartupScript(this.GetType(), alertScript, "alert('help!!!');", true);
I can step through this and it all seems to work but my alert is not displayed. Cionfused now so any help appreciated.
Also when I view the source after this call I cannot see the alert in the page source which I would expect to from memory of how it worked previously.