p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 1.0 and 1.1 Basics (http://p2p.wrox.com/forumdisplay.php?f=60)
-   -   Propogating changes in child window to parent (http://p2p.wrox.com/showthread.php?t=48065)

Scripts82 September 20th, 2006 04:27 AM

Propogating changes in child window to parent
 
Hi,

Need some help about propogating changes from child window to parent window... the simplified scenario is as follows:


I have an ASP.NET page (the parent --> A.aspx) in one IE Window: "A", with a button control and a textbox control.

When I click on the button in "A", it will open a new ASP.NET page (the child --> B.aspx) in a new IE Window: "B", with a drop down list box and a button.

The user will choose the desired option in "B" and then click on the button in "B".

Upon clicking on the button, window "B" will close and the option selected in the drop down list box will be written into the textbox in "A".

How do I do it using ASP.NET? Can I just do it purely with ASP.NET or do I have to do write client side scripts to handle this?


Thanks in advance!

Scripts82

dparsons September 20th, 2006 06:00 AM

I would use Javascript to send the value back to the parent page; the only real way to do this using just .NET would be to set a session variable in B, close that window, refresh A and have it check for the exsistance of the session.

--Stole this from a moderator

I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

Scripts82 September 20th, 2006 09:11 AM

ok thanks... I'll start looking around that topic to see how to do it...

Scripts82

dparsons September 20th, 2006 09:18 AM

You can do it in straight JS but I would probably use a combo of the 2 like this:

string sJavaScript;

sJavaScript += "<script language=javascript>";
sJavaScript += "window.location.opener.href='./somepage.aspx?value=" + ddl.SelectedItem.Value + "';";
sJavaScript += "window.close();";
sJavaScript += "</scr" + "ipt>";
Response.Write(sJavaScript);

--Stole this from a moderator

I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

iamrashida83 September 22nd, 2006 07:07 AM

Suppose the id of textbox in parent i.e. A.aspx is txtMyTextBox, the id of DropDownList in child i.e. B.aspx is ddlMyDropDownList and SubmitButton in child is btnSubmit

JavaScript In B.aspx

<script language='javascript'>
function UpdateParent()
{

 var ParentElement = window.opener.document.getElementById('txtMyTextBo x');

 var ChildElement = window.opener.document.getElementById('ddlMyDropDo wnList');

 ParentElement.innerText = ChildElement.options[ChildElement.selectedIndex].value;

 window.close();

}
</script>

In child form i.e. B.aspx add attribute in the code file as

btnSubmit.Attributes.Add("OnClick", "UpdateParent();");



Regards,
Rashida
www.akaas.net


All times are GMT -4. The time now is 01:17 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.