Modal Pop-up Dialogs in ASP.NET
Internet Explorer supports showModalDialog and most other browsers like Mozilla Firefox use modal=yes. Here’s a simple function that checks the browser type and returns appropriate JavaScript code to call a Modal Popup:
public static string ModalPopup (string URL, string Width, string Height)
{
if (Page.Request.Browser.MajorVersion > 4 &&
Page.Request.Browser.Browser == "IE")
{
return "window.showModalDialog('" + URL + "'," +
null,'status:no;dialogWidth:" + Width +
";dialogHeight:" + Height + ";scroll:yes;" +
"dialogHide:true;help:no');";
}
else
{
return "window.open('" + URL + "', null," +
"'status=no,modal=yes,width=" + Width +
",height=" + Height + ",scroll=yes," +
"scrolling=yes,scrollbars=yes');";
}
}
An example call would be:
btnInfo.Attributes.Add("onclick", ModalPopup("info.aspx", "400px", "500px"));
Ofcourse, you may want to tweak the function to automatically center the dialog based on Width/Height or add Left and Top properties, etc.

