Friday, August 11, 2006

Javascript ASP.NET MessageBox

In Windows Forms it is very easy to pop up a status message by calling MessageBox.Show(“message”). It is that kind of object model we want in ASP.NET for printing out JavaScript alerts. We want Alert.Show(“message”) in ASP.NET.

JavaScript: Alert.Show(”message”) from ASP.NET code-behind

Simple and Elegant. Makes you wonder why somthing like this was not included with ASP.NET 2.0.

1 comment:

Howard Rothenburg said...

' MessageBox
'Add a scriptmanager to the ASP.Net Page


Dim sMsg As String = "My Message"

ScriptManager.RegisterStartupScript(Page, Page.GetType, Guid.NewGuid().ToString(), "alert('" & sMsg & "')", True)