If you are also using Ajax, you have a choice of 2 ways to program that alert from the code behind: Response.Write or ScriptManager.RegisterStartupScript.
The difference is that Response.Write will popup an alert box before the page loads, ie on a white background, and ScriptManager.RegisterStartupScript will pop it up after the page has loaded, so the page is visible behind the popup.
I prefer using ScriptManager.RegisterStartupScript, but maybe I just haven't come across an application where Response.Write would be better.
In any case, the following is the code to use for each case:
Response.Write("<script language='javascript'>       alert('This pops up on a blank page      (ie before the page loads) using response.write');</SCRIPT> ");
ScriptManager.RegisterStartupScript(this, typeof(Page), UniqueID,   "alert('This pops up after the page loads,      using ScriptManager.RegisterStartupScript');", true);
I have also popped up an alert on pageload by using the following in the html < body> tag of the page:
The \r\n causes a line break.
<body onLoad="alert('Update. \r\n \r\n Thank you for your interest, \r\n however, \r\n we are not taking any new orders at this time.')" >
No comments:
Post a Comment