In your base class for example,
Utils.cs write the following method
public static void ShowAlert(Page currentPage, string message)
{
StringBuilder sb = new StringBuilder();
sb.Append("alert('");
sb.Append(message);
sb.Append("');");
currentPage.ClientScript.RegisterStartupScript(typeof(Utils), "showalert", sb.ToString(), true);
}
Now where ever you want to show your alert message just call it.
for example
In Hello.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
Utils.ShowAlert(this, "Hello");
}
Utils.cs write the following method
public static void ShowAlert(Page currentPage, string message)
{
StringBuilder sb = new StringBuilder();
sb.Append("alert('");
sb.Append(message);
sb.Append("');");
currentPage.ClientScript.RegisterStartupScript(typeof(Utils), "showalert", sb.ToString(), true);
}
Now where ever you want to show your alert message just call it.
for example
In Hello.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
Utils.ShowAlert(this, "Hello");
}
No comments:
Post a Comment