C
Curious Trigger
Hi there,
programming with Visual Studio 2005 and ASP.NET 2.0 I want to open a modal
dialog from Default.aspx.
I searched the net and many newsgroups but I couldn't find any solution.
First I tried using two aspx pages with standard controls and all those
post-backs and their attributes OnClientClick. Since this didn't work, i
reduced it to a default.aspx page opening a pure html-page as a modal
dialog.
On the second form I am using a input control of type "submit" and a little
client side script "Sub Submit1_onclick" which sets the return value and
calls "window.close()". But instead of closing the modal dialog and
returning to the caller window, it opens a new internet explorer instance
showing the same controls as the modal dialog window. Very annoying!
All I can do to close the modal dialog is clicking the white cross on the
red background in the right corner of the dialog's window. This will close
the dialog and return to the caller's window but has several drawbacks: the
return value gets lost and the user cannot choose between Ok and Cancel.
Here's my code:
======== Default.aspx =====================================
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"
Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<meta content="text/VBScript" http-equiv="content-script-type" />
<title>Main Page</title>
<script language="vbscript" type="text/vbscript">
Sub Button2_onclick
Dim Result 'as string
Result = window.showModalDialog("StandardHtmlPage.htm",
"","help:no;status:no;unadorned:yes")
window.alert("Dialog Result = '" & Result & "'")
End Sub
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
The Main Page - please choose a command<br />
<input id="Button2" type="button" value="HTML page with
Standard HTML-controls" />
</div>
</form>
</body>
</html>
======== StandardHtmlPage.htm =====================================
<%@ Page Language="VB" AutoEventWireup="false"
CodeFile="StandardHtmlDialog.aspx.vb" Inherits="StandardHtmlDialog" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<meta content="text/VBScript" http-equiv="content-script-type" />
<title>No ASP.NET!</title>
<script language="vbscript" type="text/vbscript">
Sub Submit1_onclick
' Problem: window.close() führt vom Dialog zu neuem IE-Fesnter mit
gleichem Inhalt aber Menuzeile etc.
window.returnValue = "say hello from dialog"
window.alert("onclick returns '" & window.returnValue & "'")
window.close()
End Sub
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
A pure HTML-page with HTML-controls only<br />
<input id="Text1" type="text"/><input id="Submit1" type="submit"
value="submit"/>
</div>
</form>
</body>
</html>
programming with Visual Studio 2005 and ASP.NET 2.0 I want to open a modal
dialog from Default.aspx.
I searched the net and many newsgroups but I couldn't find any solution.
First I tried using two aspx pages with standard controls and all those
post-backs and their attributes OnClientClick. Since this didn't work, i
reduced it to a default.aspx page opening a pure html-page as a modal
dialog.
On the second form I am using a input control of type "submit" and a little
client side script "Sub Submit1_onclick" which sets the return value and
calls "window.close()". But instead of closing the modal dialog and
returning to the caller window, it opens a new internet explorer instance
showing the same controls as the modal dialog window. Very annoying!
All I can do to close the modal dialog is clicking the white cross on the
red background in the right corner of the dialog's window. This will close
the dialog and return to the caller's window but has several drawbacks: the
return value gets lost and the user cannot choose between Ok and Cancel.
Here's my code:
======== Default.aspx =====================================
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"
Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<meta content="text/VBScript" http-equiv="content-script-type" />
<title>Main Page</title>
<script language="vbscript" type="text/vbscript">
Sub Button2_onclick
Dim Result 'as string
Result = window.showModalDialog("StandardHtmlPage.htm",
"","help:no;status:no;unadorned:yes")
window.alert("Dialog Result = '" & Result & "'")
End Sub
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
The Main Page - please choose a command<br />
<input id="Button2" type="button" value="HTML page with
Standard HTML-controls" />
</div>
</form>
</body>
</html>
======== StandardHtmlPage.htm =====================================
<%@ Page Language="VB" AutoEventWireup="false"
CodeFile="StandardHtmlDialog.aspx.vb" Inherits="StandardHtmlDialog" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<meta content="text/VBScript" http-equiv="content-script-type" />
<title>No ASP.NET!</title>
<script language="vbscript" type="text/vbscript">
Sub Submit1_onclick
' Problem: window.close() führt vom Dialog zu neuem IE-Fesnter mit
gleichem Inhalt aber Menuzeile etc.
window.returnValue = "say hello from dialog"
window.alert("onclick returns '" & window.returnValue & "'")
window.close()
End Sub
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
A pure HTML-page with HTML-controls only<br />
<input id="Text1" type="text"/><input id="Submit1" type="submit"
value="submit"/>
</div>
</form>
</body>
</html>