473,394 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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

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>
Sep 22 '06 #1
1 7617
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 <headsection
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" <Cu*************@nospam.gmx.netschrieb im Newsbeitrag
news:%2****************@TK2MSFTNGP03.phx.gbl...
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>


Sep 24 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Lee | last post by:
I am using a modal window and an iFrame to try and pull a return value back. I am doing this across domains. I have the value returned from the modal window to the iFrame window but I can not...
4
by: Simon Wigzell | last post by:
I have a couple of utility windows - a calculator and a calendar that popup from my main window. I would like them to always stay in front of the parent window until they are shut down with there...
4
by: webdev | last post by:
Hi, I have an application built for the education market in which I open popup windows containing ASP scripts which when the user clicks the 'Update' button, the database is updated and the...
2
by: Namespace | last post by:
Hi I am having a problem with opening a new browser window through a client-side javascript (window.open/_blank) function. The window do "pop up" but behind the window where I pushed the "pop...
0
by: prakash2kr | last post by:
i am using the following code to show popup window window.showModalDialog("WebForm2.aspx","","height=200px;width=300px"); how can i pass the value from WebForm2.aspx to parent window... i...
1
by: elizayiu | last post by:
Hi, I need to write a webpage which does the following: - open up a window and pass parameters into it (i.e. need to call showModalDialog() or showModelessDialog()) - contains jscript to...
1
by: CutCopyPaste | last post by:
Hi , I am trying to open a modal window but if t he window is already opened i need to just set the focus back . The Code is working fine in one environment but not live system on live system...
1
by: Ramachand | last post by:
Actually I have to call a dialog window "Dwin1" from a Parent Window. From Dwin1, I have to call another Dialog Window "Dwin2".if user close the Dialog Window "Dwin2", i have to refersh the Dwin1....
1
by: varunvashishth | last post by:
hi, I'm facing a problem with displaying a child jsp on top of parent jsp. on clicking a link in parent jsp the child jsp opens up and it has some list of values and other textboxes which gets...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.