-2

I have a JavaScript function that looks like this. I need help passing these values from JavaScript of the pop up window to the parent window. I know that I have to use

window.opener.document.getelementbyD("ID Of TextBox");

method in my child aspx page but the textbox is inside another user control. How do I do it?

function(PersonName, EmailID){
    //assign these values to text boxes of  a parent window 
    //the text boxes of parent window are inside of  control
}

Regards
-Vishu

4

1 回答 1

0

You could write two plain JS-functions. One (setValues) in your "parent" Window which will be called by your pop up. And one in your pop up (setValuesToParent) collecting the values and calling function in your parent window. Please dont forget that this example is written in plain JavaScript and does not use any asp.net stuff.

// in your pop up 
function setValuesToParent() {
    var PersonName= document.getElementById('PersonNameInPopUp').value;
    var EmailID = document.getElementById('EmailIDInPopUp').value;
    window.opener.setValues(PersonName, EmailID); // this is the important line
}



// in your parent window
function setValues(PersonName, EmailID) {
    document.getElementById('PersonName').value = PersonName;
    document.getElementById('EmailID').value = EmailID;
}
于 2013-03-05T07:56:05.690 回答