Reputation: 2058
I have two web pages, Page1
and Page2
, which can both open the same child popup page.
If the parent page is Page1
I want certain input from the Child page to returned to the parent page and if the parent page is Page2
I want other information to be returned.
I do identify who is the parent page and how do I return the input to it and have it show in the proper text box or DroDownList?
I tried using Request.UrlReferrer
putting results in a string variable and I got an error 'object not set to an instance'.
Upvotes: 1
Views: 4139
Reputation: 7438
As both the pages can be parent , write the a javascript function that works as receiver on both the page and write code in it as per your requirement.
e.g.
javascript on Parent page:
SetDataFromPopup(data)
{
document.getElementById('TextBox1ClientId').value = data;
}
On popup write the following line
window.opener.SetDataFromPopup(data);
this should be called on the event where you want to pass the data e.g. suppose you have a button on client click of it you want to pass the data , the code should look like:
<input id="btnSave" type="submit" onclick="window.opener.SetDataFromPopup(data);" >Save</input>
Upvotes: 3