Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > window.showModalDialog() works perfect, but returning to parent-page doesnot

Reply
Thread Tools

window.showModalDialog() works perfect, but returning to parent-page doesnot

 
 
Curious Trigger
Guest
Posts: n/a
 
      09-22-2006
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 />
&nbsp;<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>


 
Reply With Quote
 
 
 
 
Curious Trigger
Guest
Posts: n/a
 
      09-24-2006
Hi,

it seems that I found a solution: in the form which is opened as modal
dialog you have to add a <base target="_self" />-tag to the <head> section
as shown in the following example:

<head runat="server">
<!-- <base href="_self" /> -->
<base target="_self"/>
....
</head>

I read in another newsgroup, that until ASP.NET 1.1 you could achive the
same result with the tag <base href="_self" />. I didn't check this, but
this solution does not work any longer with ASP.NET 2.0. Therefore you have
to use the target-attribute.

Hope this helps anyone with a similar problem.

Curious Trigger

"Curious Trigger" <(E-Mail Removed)> schrieb im Newsbeitrag
news:%(E-Mail Removed)...
> 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 />
> &nbsp;<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>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Microsoft.Web.UI.WebControls doesnot work when upladed to web hosting server dave ASP .Net 3 01-19-2006 03:07 AM
When I turn on my PC, it works, works, works. Problem! Fogar Computer Information 1 01-17-2006 12:57 AM
Doesnot allow to debug or asks for username and password in visual studio.net academic 2003 Anita ASP .Net 6 01-18-2005 08:04 PM
After rebooting my PC works, works, works! Antivirus problem? Adriano Computer Information 1 12-15-2003 05:30 AM
[Q]function doesnot declare 'throws...' even though it can potentially throw an exception... Paul Java 1 08-14-2003 06:37 PM



Advertisments