When you are using Ajax update panel, then normal alert function will not work. Here is the code to show alert message on button click(submit, cancel etc.)
public void ShowAjaxMessage(System.Web.UI.Page page, string
strMsg)
{
string
alertScript = "alert('" + strMsg
+
"')";
ScriptManager.RegisterStartupScript(page, this.GetType(), "1", alertScript, true);
}
How to call this function on button click:
Ex.
private void SaveRecord()
{
//Code
to save data
ShowAjaxMessage(this.Page, "Data
saved successfully!")
}
In alert function we are using
ScriptManager.RegisterStartupScript(Page
page, Type type, string key, string script, bool addScriptTags)
function.
We have to add
namespace to use ScriptManager
i.e. using
System.Web.UI;