Question

I have an usercontrol with an aspxGridview inside it. I use this usercontrol in my page in a separate updatepanel (named updListView). In another update panel (updForm) I have a button and its code checks some conditions to raise a javascript alert message. When the alert message pops up, user control stays but the gridview temporarily disappears as long as the alert message is showing up. As soon as I close the alert, the grid view appears. It is a bug that I need to fix but could not find any solution.

Any help would be appreciated.

I am using server side alert message

string strScript = String.Format("javascript:alert('{0}');", "My Message");
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "AlertMessage", strScript, true);
Was it helpful?

Solution

I used the above code to achieve the desired result

if (!String.IsNullOrEmpty(message.Trim()))
{
  message = message.Replace("\\n", "\\\\n");
  string script = "setTimeout(\"alert('" + message + "');\",0);";
  System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), script, true);             
}

Call this method and pass the message string

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top