473,396 Members | 1,933 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,396 software developers and data experts.

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(pageToGoTo) 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.showModalDialog(\"{0}?
pageToGoTo=testWebForm01.aspx\", \"testWebForm01.aspx
\" ,'dialogWidth=520px;dialogHeight=650px;dialogTop=1 25px;dialogLeft=125px;');*",
ResolveUrl("~/Container.aspx"));
Page.ClientScript.RegisterStartupScript(GetType(),
"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.QueryString["pageToGoTo"];
frameTest.Attributes["src"] = pageToGoTo;
This is then able to load the testWebForm01.aspx in the iframe
control.
Now on a button click event on testWebForm01.aspx 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.aspx
function refreshParent()
{
window.opener.location.href = window.opener.location.href;
if (window.opener.progressWindow)
{
window.opener.progressWindow.close()
}
window.close();
// parent.refresh();
// self.close();
}
and called it on the server side button_click event as follows
string script = "refreshParent()";
Page.ClientScript.RegisterStartupScript(GetType(),
"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 9378
you iframe does not have an opener, the page containing it does, so you
want window.parent.opener (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(pageToGoTo) 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.showModalDialog(\"{0}?
pageToGoTo=testWebForm01.aspx\", \"testWebForm01.aspx
\" ,'dialogWidth=520px;dialogHeight=650px;dialogTop=1 25px;dialogLeft=125px;');*",
ResolveUrl("~/Container.aspx"));
Page.ClientScript.RegisterStartupScript(GetType(),
"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.QueryString["pageToGoTo"];
frameTest.Attributes["src"] = pageToGoTo;
This is then able to load the testWebForm01.aspx in the iframe
control.
Now on a button click event on testWebForm01.aspx 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.aspx
function refreshParent()
{
window.opener.location.href = window.opener.location.href;
if (window.opener.progressWindow)
{
window.opener.progressWindow.close()
}
window.close();
// parent.refresh();
// self.close();
}
and called it on the server side button_click event as follows
string script = "refreshParent()";
Page.ClientScript.RegisterStartupScript(GetType(),
"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
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...
1
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...
2
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...
10
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...
3
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...
4
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...
1
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...
1
by: bhargavi ramineni | last post by:
I have used the following javascript code to get a child window for parent window. childWin...
9
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...
0
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...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...

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.