473,547 Members | 2,290 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Refreshing parent page from a child page opened as a modal dialog box

Default.aspx is the starting page containing a control(ascx) which
has
asp:button control on it. On the button click event it has to open a
new page as a modal control. Since refreshing a page in a dialog box
ended up opening up a new browser window with the aspx page, I read
on
a forum that I should use the iframe control and since I have to open
a bunch of pages as diaogboxes, I created a general
page(Container. aspx) which has an iframe control on it, which I then
pass a parameter(pageT oGoTo) specifying the aspx page that has to be
opened as a dialogbox.

Sequence of events and code are as follows:
On the default.aspx page I have added a control with a button. On the
button click server side event on that control, I call an aspx page.
string script = String.Format(" window.showModa lDialog(\"{0}?
pageToGoTo=test WebForm01.aspx\ ", \"testWebForm01 .aspx
\" ,'dialogWidth=5 20px;dialogHeig ht=650px;dialog Top=125px;dialo gLeft=125px;'); *",
ResolveUrl("~/Container.aspx" ));
Page.ClientScri pt.RegisterStar tupScript(GetTy pe(),
"test",
script, true);
On the Container.aspx I have an iframe control called frameTest which
I load on Page_Load event as follows
string pageToGoTo =
Request.QuerySt ring["pageToGoTo "];
frameTest.Attri butes["src"] = pageToGoTo;
This is then able to load the testWebForm01.a spx in the iframe
control.
Now on a button click event on testWebForm01.a spx I want to close the
testWebForm01 form and reload default.aspx so that the control on
default.aspx. I added the following javascript code to
testWebForm01.a spx
function refreshParent()
{
window.opener.l ocation.href = window.opener.l ocation.href;
if (window.opener. progressWindow)
{
window.opener.p rogressWindow.c lose()
}
window.close();
// parent.refresh( );
// self.close();
}
and called it on the server side button_click event as follows
string script = "refreshParent( )";
Page.ClientScri pt.RegisterStar tupScript(GetTy pe(),
"test",
script, true);
I keep getting window.opener is null error.
I read on another forum that if we have used showModalDialog method
then window.opener method is not initialized.
I did play around with trying to initialize it but haven't had any
success.
Does anybody have any idea on how refreshing the parent page can be
accomplished? Please let me know.
Thanks
Sumeet
Oct 31 '08 #1
1 9386
you iframe does not have an opener, the page containing it does, so you
want window.parent.o pener (or however deep you are).

as showModalDialog is now w3c complaint it a bad practice to start using
it. now days this is usally done with a floating div (sometimes
containing an iframe). usually the div is dislayed, and the background
page is gray'd out. there are a lot of sample modal dialogs that work
this way. there are several for jQuery and the ajax toolkit has one.

-- bruce (sqlwork.com)
Bali wrote:
Default.aspx is the starting page containing a control(ascx) which
has
asp:button control on it. On the button click event it has to open a
new page as a modal control. Since refreshing a page in a dialog box
ended up opening up a new browser window with the aspx page, I read
on
a forum that I should use the iframe control and since I have to open
a bunch of pages as diaogboxes, I created a general
page(Container. aspx) which has an iframe control on it, which I then
pass a parameter(pageT oGoTo) specifying the aspx page that has to be
opened as a dialogbox.

Sequence of events and code are as follows:
On the default.aspx page I have added a control with a button. On the
button click server side event on that control, I call an aspx page.
string script = String.Format(" window.showModa lDialog(\"{0}?
pageToGoTo=test WebForm01.aspx\ ", \"testWebForm01 .aspx
\" ,'dialogWidth=5 20px;dialogHeig ht=650px;dialog Top=125px;dialo gLeft=125px;'); *",
ResolveUrl("~/Container.aspx" ));
Page.ClientScri pt.RegisterStar tupScript(GetTy pe(),
"test",
script, true);
On the Container.aspx I have an iframe control called frameTest which
I load on Page_Load event as follows
string pageToGoTo =
Request.QuerySt ring["pageToGoTo "];
frameTest.Attri butes["src"] = pageToGoTo;
This is then able to load the testWebForm01.a spx in the iframe
control.
Now on a button click event on testWebForm01.a spx I want to close the
testWebForm01 form and reload default.aspx so that the control on
default.aspx. I added the following javascript code to
testWebForm01.a spx
function refreshParent()
{
window.opener.l ocation.href = window.opener.l ocation.href;
if (window.opener. progressWindow)
{
window.opener.p rogressWindow.c lose()
}
window.close();
// parent.refresh( );
// self.close();
}
and called it on the server side button_click event as follows
string script = "refreshParent( )";
Page.ClientScri pt.RegisterStar tupScript(GetTy pe(),
"test",
script, true);
I keep getting window.opener is null error.
I read on another forum that if we have used showModalDialog method
then window.opener method is not initialized.
I did play around with trying to initialize it but haven't had any
success.
Does anybody have any idea on how refreshing the parent page can be
accomplished? Please let me know.
Thanks
Sumeet
Nov 1 '08 #2

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

Similar topics

1
3359
by: gopal srinivasan | last post by:
I need to know how to close a parent modal window when child modal window opens, also i need to know the syntax for writing document on the modal window on the fly, like what we do in case of normal window. Actually, I tried to close the parent window from the child modal window using parent.close syntax in onload event in child modal...
1
11545
by: Earl Teigrob | last post by:
I did a ton of searching to try and find a simple solution to this issue and finally wrote my own, which I am sharing with everyone. In my searching, I did find a very complete and robust solution at http://weblogs.asp.net/asmith/archive/2003/09/15/27684.aspx but it was far more complex then I needed. (I got lost trying to figure it all...
2
3394
by: Samy | last post by:
Hi There, I have a user control with buttons on it which I use on a aspx page (parent page). On a button click, a modal dialog(aspx page) opens up and the user enters some info in the modal dialog and clicks the save button on it. The info is saved to the DB and the parent page is refreshed. Everything works fine but for some reason the page...
10
3993
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the application. What should happen, is that the main MDI form should close, taking the child forms with it. There is code to loop through the child forms,...
3
3868
by: luna | last post by:
i have a parent form which opens a child form, i need to pass a variable back to parent then reload parent so parentopens child, child passes to parent, child closes, parent reloads its only a single variable is this possible ?
4
3607
by: raj_genius | last post by:
I hav two queries, whc are as follows: FIRSTLY: is it possible to access the controls(by name) of a parent form(MDI) from its child forms??if yes then how??plzz provide a coded example in VB if possible.. for example..i hav a menu in the parent form named "Administrator" whic has an item "mnuLogIn"..now when i click on login..another child...
1
7635
by: Curious Trigger | last post by:
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...
1
2588
by: bhargavi ramineni | last post by:
I have used the following javascript code to get a child window for parent window. childWin =window.open(url,"window","top=250,left=250,height=100,width=480,status=no,toolbar=no,menubar=no,location=no"); As the child window is not a modal dialog, user can minimize the window and do other actions in parent window. Please help me to avoid...
9
4414
by: Bali | last post by:
Default.aspx is the starting page containing a control(ascx) which has asp:button control on it. On the button click event it has to open a new page as a modal control. Since refreshing a page in a dialog box ended up opening up a new browser window with the aspx page, I read on a forum that I should use the iframe control and since I have to...
0
2052
by: Bali | last post by:
Default.aspx is the starting page containing a control(ascx) which has asp:button control on it. On the button click event it has to open a new page as a modal control. Since refreshing a page in a dialog box ended up opening up a new browser window with the aspx page, I read on a forum that I should use the iframe control and since I have...
0
7507
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7947
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7794
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6030
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5361
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5080
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3492
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3472
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
747
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.