alert from code behind asp.net

Please if you want to understand this functionality Difference between RegisterClientScriptBlock and RegisterStartupScript with asp.net. This will give you a clear idea for RigisterClientScriptBlock and RegisterStartupScript which helps you to understand how we can achieve alert from code behind as well as how can we call javascript method from code behind.

We can achieve alert from code behind asp.net:
  • Sample example of RegisterClientScriptBlock  :
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "RegisterClientScriptBlock", "alert('Using Page.ClientScript.RegisterClientScriptBlock');", true);
ScriptManager.RegisterClientScriptBlock(this.bntClientScript, this.GetType(), "RegisterClientScriptBlock", "alert('Using Page.ClientScript.RegisterClientScriptBlock');", true);
  • Sample example of RegisterStartupScript :
Page.ClientScript.RegisterStartupScript(this.GetType(), "RegisterClientScriptBlock", "alert('Using Page.ClientScript.RegisterStartupScript');", true);
ScriptManager.RegisterStartupScript(this.bntClientScript, this.GetType(), "RegisterClientScriptBlock", "alert('Using Page.ClientScript.RegisterStartupScript');", true);

Download code for alert from code behind asp.net

Leave a Reply