|
Subject:
|
Propogating changes in child window to parent
|
|
Posted By:
|
Scripts82
|
Post Date:
|
9/20/2006 4:27:44 AM
|
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
|
|
Reply By:
|
dparsons
|
Reply Date:
|
9/20/2006 6:00:07 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.
|
|
Reply By:
|
Scripts82
|
Reply Date:
|
9/20/2006 9:11:30 AM
|
ok thanks... I'll start looking around that topic to see how to do it...
Scripts82
|
|
Reply By:
|
dparsons
|
Reply Date:
|
9/20/2006 9:18:26 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.
|
|
Reply By:
|
iamrashida83
|
Reply Date:
|
9/22/2006 7:07:03 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('txtMyTextBox');
var ChildElement = window.opener.document.getElementById('ddlMyDropDownList');
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
|