Search This Blog

2009-05-06

Server side messagebox

How to create server side message box for aspx page:

You can show server side messagebox(javascript alert) by the following method.

Create a class file ServerMessageBox.cs and write a method Show() as follows:



public static class ServerMessageBox
{
public static void Show(string message, Control owner)
{
Page page = (owner as Page) ?? owner.Page;
if (page == null) return;
page.ClientScript.RegisterStartupScript(owner.GetType(),
"ShowMessage", string.Format("
", message));
}
}



call the method show from your button click event.


ServerMessageBox.Show("The File Already Exist, Please Change The File Name!", this);

1 comment:

forexxx said...

Helo there,
thanks for saving my lot of time...

Cheers...