Its easy and common to us but then also we are writing a same code again and again.
Here we have made a common function for show message box, which is more simple and better to look, call and apply.
Step 1: Put below code in Common class file.(if not created then create for all common functions. its a good habit)
//-----------Implementation-------------
public static void MessageBox(Page p,string msg)
{
//System.Web.UI.Page p = new Page();
ClientScriptManager cm = p.ClientScript;
cm.RegisterStartupScript(p.GetType(), "alert", "<script>alert('"+msg+"');</script>");
}
Step 2: how to call
Common.MessageBox(this.Page, "Test Message.");