Parent-Child window communication

  • Thread starter Thread starter SJ
  • Start date Start date
S

SJ

Here's the scenario

Website has a button that pops up a confirmation window
when clicked.
When the user clicks the "confirm" button in this popup
window, I want all the following to happen :
a) Form data on the Parent (opener) page to be submitted.
b) Some (asp.net) code behind executed for the Parent
page.
c) Pop-Up window to close.

What would be the best approach to do this?



-SJ
 
Website has a button that pops up a confirmation window
when clicked.
When the user clicks the "confirm" button in this popup
window, I want all the following to happen :

Use javascript to submit the parent page.
 
SJ,

I have a javascript in my Javascript componet which you can download for
free from my website, www.aboutfortunate.com, that contains code for
attaching a javascript confirmation window to asp.net Buttons. The code on
my site is all free and you can download the entire projects for any of the
components on the site (plus a help file). The javascript component contains
a lot of useful functions, but even if you don't find the whole component
useful you could always look at the source code and pull out just the pieces
you need.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
a) window.opener.document.forms[0].submit();
b) Submitting page would execute the code behind method in Page_Load
c) window.close();
 
a) window.opener.document.forms[0].submit();
b) Submitting page would execute the code behind method in Page_Load
c) window.close();

Just out of curiosity, What if I want to pop-up a window with
some form data that needs to be submitted? Would it be wise
to have a pop-up like that or just change my design to incorporate
this form data into my main-page?
The reason I ask this is because don't browsers like firefox do a
real good job of preventing pop-up windows? Is it possible to fool
the browser and open a window anyway? If so, how.

-SJ
 
if I want to pop-up a window with
some form data that needs to be submitted? Would it be wise
to have a pop-up like that

Not aware of any disadvatages in doing this. One advatage in
submitting popup form to itself is that you could reuse same popup page
from multiple parent pages if needed. But if you plan to use modal
window(ShowModalDialog) , submitting to itself will popup another
window. To submit modal winows to itself you will be able to load the
page with form in an Iframe.
The reason I ask this is because don't browsers like firefox do a
real good job of preventing pop-up windows? Is it possible to fool
the browser and open a window anyway? If so, how.

not very sure on this. Do they block the modal windows too ? is there a
modal winow in firefox ?
 
Not aware of any disadvatages in doing this. One advatage in
submitting popup form to itself is that you could reuse same popup page
from multiple parent pages if needed. But if you plan to use modal
window(ShowModalDialog) , submitting to itself will popup another
window. To submit modal winows to itself you will be able to load the
page with form in an Iframe.


not very sure on this. Do they block the modal windows too ? is there a
modal winow in firefox ?

Well, I dont think that is going to work for me either.
Basically, what I'm trying to do is something like this

website.aspx:
<form id="form1" runat="server">
<asp:TextBox id="Mytext" runat="server" />
<asp:imageButton id="ResetButton" imageURL="blah.gif" runat="server" />
</form>

website.aspx.cs:
private void ResetButton_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{
// Code that will pop-up a window

// "form1" Processing
}

As you can see above, I need 2 things to happen when the "ResetButton" is
clicked.
a) form submission and processing in the _Click event handler
b) Popup a window

Now, if I use regular HTML buttons, I can use an
"onClick=someJavascriptFunction()" event in the website.aspx to pop-up a
window, but that prevents me from submitting/processing the form data using
the ResetButton_Click event handler in the website.aspx.cs file.
I know that I could do form submission from the someJavascriptFunction() ,
but I dont want to do that.

I need the code-behind to open this pop-up window. If thats even possible.

I hope that makes sense?

Thanks.
 
No need of 'form submission from the someJavascriptFunction() '
From Code behind (ResetButton_Click event) you could use
Page.RegisterStartupScript("<script>someJavascriptFunction();</script>");

Only way to open a pop-up window is writing/generating client side
script.
 
Replace "// Code that will pop-up a window" in "private void
ResetButton_Click"
with below line of code

Page.RegisterStartupScript("somename","<script>someJavascriptFunction();</script>");
 
Back
Top