Trying to redirect the parent page from popup
-
Hi, I have this popup page where i am doing this in the button click:
Response.Write("<script language='javascript'>function changeParent(){window.opener.document.getElementById('ctl00$ContentPlaceHolder1$txtChange').value='Change';}window.close();</script>");
In the parent form I have a hidden textbox set to autopostback=true and in the textchanged event handler, I am doing response.redirect(url). In the script above(in the popup), I am changing the value of the textbox located in the parent page. So, I was expecting it to work, but its not. Any idea? Thanks. -
Hi, I have this popup page where i am doing this in the button click:
Response.Write("<script language='javascript'>function changeParent(){window.opener.document.getElementById('ctl00$ContentPlaceHolder1$txtChange').value='Change';}window.close();</script>");
In the parent form I have a hidden textbox set to autopostback=true and in the textchanged event handler, I am doing response.redirect(url). In the script above(in the popup), I am changing the value of the textbox located in the parent page. So, I was expecting it to work, but its not. Any idea? Thanks.You can call the function __doPostback event in the parent window. Take a look at the parent's source and see what script the hidden field is invoking (in case it's not the default __doPostback). Add that code to your popup window script.
-
You can call the function __doPostback event in the parent window. Take a look at the parent's source and see what script the hidden field is invoking (in case it's not the default __doPostback). Add that code to your popup window script.
I've found this in the parent's source:
onchange="javascript:setTimeout('__doPostBack(\'ctl00$ContentPlaceHolder1$txtChange\',\'\')', 0)"
But what would be the syntax to call this from the popup window script? Do I call it after changing the value? like:Response.Write("<script language='javascript'>function changeParent(){window.opener.document.getElementById('ctl00$ContentPlaceHolder1$txtChange').value='Change'; __doPostBack(\'ctl00$ContentPlaceHolder1$txtChange\',\'\')', 0); }window.close();</script>");
Thanks. -
I've found this in the parent's source:
onchange="javascript:setTimeout('__doPostBack(\'ctl00$ContentPlaceHolder1$txtChange\',\'\')', 0)"
But what would be the syntax to call this from the popup window script? Do I call it after changing the value? like:Response.Write("<script language='javascript'>function changeParent(){window.opener.document.getElementById('ctl00$ContentPlaceHolder1$txtChange').value='Change'; __doPostBack(\'ctl00$ContentPlaceHolder1$txtChange\',\'\')', 0); }window.close();</script>");
Thanks.Put a client side javascript function call in the onchange event of your field in the parent window. That should fire when your popup changes the field. You can force the postback in that function.