?
Solved

How to use showModalDialog in asp.net?

Posted on 2003-10-29
6
Medium Priority
?
803 Views
Last Modified: 2012-06-27
On WebForm1.aspx, I have a linkbutton to call a JavaScript function to show a modal web page, WebForm2.aspx. Like this:

function ShowNewPage()
{
window.showModalDialog("WebForm2.aspx","","width=400; height=200; resizable=yes; scrollbars=yes; top=300; left=300");
}

On WebForm2.aspx, I have a web control button. If I click on it, something weird happened. Instead of post back to the same page (WebForm2.aspx), it opens another web page, which is unexpected behavior.

Does anybody know how to fix this problem and let modal web page post back to itself?

Thanks a lot.
0
Comment
Question by:BruceCheng
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 2

Expert Comment

by:Inteliscape
ID: 9650386
this is how in one page.

<HTML>
<HEAD>
<TITLE>page1.HTM</TITLE>
</HEAD>
<BODY>
<INPUT type=textbox id=mmytext tabIndex=1>
<SCRIPT>
function ShowNewPage()
{
mmytext.value=window.showModalDialog("page1.HTM","","width=400; height=200; resizable=yes; scrollbars=yes; top=300; left=300");
return;
}
function leave(ret){
      window.returnValue = ret;
      window.close();
}
</SCRIPT>
<br>
<INPUT id=button1 onclick=leave(false); tabIndex=1 type=button value=No>&nbsp;&nbsp;&nbsp;
<INPUT id=button2 onclick=leave(true); tabIndex=2 type=button value=Yes>
<br>
<div onClick="ShowNewPage()"><b>Click Here</b></div>
</BODY>
</HTML>
0
 
LVL 1

Author Comment

by:BruceCheng
ID: 9650540
I know how to use showModalDialog. My question is, in case of .NET, if the modal page (in your case page1.HTM) post back to itself, it opens a new modaless windows.

Which is, in my example, on the opened modal window, WebForm2.aspx, if I click a button or select an new item from a drop down list, WebForm2.aspx will post back to itself automatically. At this time, instead of refreshing the same WebForm2.aspx, it opens another modaless page. How can I just refresh the same modal window page without opening a new window.

Thanks.
0
 
LVL 2

Accepted Solution

by:
Inteliscape earned 1000 total points
ID: 9663429
There is no any direct solution.

But you can work with iframes or layers.

something like this in the modal page

<iframe id = "tst" width="100%" height="100%"  src="WebForm2.aspx"> </iframe>

the rest are easy you have a full functional page and the id of the page.

i hope know its ok.



0
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 

Expert Comment

by:muffish
ID: 11715553
Bruce Cheng,

In the child form ,you open html view.
You will find html tag <body >

type in property,  onblur="this.focus"

this is how it looks like

<BODY  onblur="this.focus">


0
 

Expert Comment

by:Polyktor
ID: 11750363
This is all the code you need to avoid the new windows on postback with showModalDialog:

      <base TARGET="_self">

Put this in your <head> tag on your page.

You don't need to mess with other frames. I'm glad I found this before going the frames route.

-R
0
 

Expert Comment

by:HappySurfer
ID: 11757402
Thanks Polyktor

It is a better solution than using a empty page with a iframe.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question