Thursday, October 13, 2011

Prevent popup appearing before the page is fully rendered.

StringBuilder strScript = new StringBuilder();
strScript.Append(" ");
ClientScript.RegisterStartupScript(this.GetType(), "Pop", strScript.ToString());

When you click the Save button, the popup may appear immediately after the postback with the white screen background.


Solution 1:
StringBuilder strScript = new StringBuilder();
strScript.Append(" ");
ClientScript.RegisterClientScriptBlock(this.GetType(), "Pop", strScript.ToString());

Solution 2: Add a timer to the alert

strScript.Append("window.setTimeout('displayMessage()', 1000);\n");

No comments: