Tuesday, August 19, 2008

Server Message Box

ASP.NET server code can provoke the display of a message box in the client's browser by registering a client script within the page's output. The following example displays a message box when the page is rendered :

string escapedMessage = message.Replace("'", @"\'");
string script = String.Format("alert('{0}');", escapedMessage);
this.ClientScript.RegisterStartupScript(typeof(Page), "MessageBox", script, true);

No comments: