I have used below code to show the alert messages from code behind in asp.net.
Home.aspx:
<asp:ScriptManager runat="server" ID="smHome"></asp:ScriptManager>
Home.aspx.cs:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowStartStatus", "javascript:alert('Process is started');", true);
LoadGridView();
}
}
protected void LoadGridView()
{
//ADO.NET code here
ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowCompletedStatus", "javascript:alert('Process is completed');", true);
}
But both of the alert messages have been shown continuously after completing the ADO.NET process that is available in LoadGridView() method. I want to show the first alert message before LoadGridView() method. Also I need to show the second alert message after completing ADO.NET process. I have also tried ClientScriptManager.RegisterClientScriptBlock method to show these alert messages. But it is also not working as expected. How to resolve the above issue?