Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i want to pass value between aspx pages. I created one aspx page which acts as parent and another aspx page which acts as child. Now i opened the child page using window.open(). After the child is opened i passed some value to the parent using window.opener.document.getElementById().value .here is the code snippet

Parent page:
C#
function open_child()
  {
  window.open("child.aspx");
  }


Child page:
C#
function passvalue()
{
window.opener.document.getElementById("TextBox1").value="hello";//TextBox1 is in parent page

}


The above code works fine when im passing value from normal child(aspx form page) to parent(aspx form page). But the problem is while passing value from child(aspx form page) to parent which is a content page of a masterpage. The error i get is window.opener is null or not an object . Any solution for this error? alternate methods are welcomed!
Posted

1 solution

try this in ok button event
//this is when u taken popup as normal (window.open) dialog it will return value to parent page
Session["id"] = CCode;
            ScriptManager.RegisterStartupScript(Page, this.GetType(), "CCode", "<script>window.opener.document.forms[0].submit();window.close();</script>", false);


//this is when u taken popup as showmodal(window.showmodaldialog) dialog it will return value to parent page
 Session["Code"] = Code;
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "A", "<script>window.returnValue = true;window.close();</script>");

read article also

Window.showmodaldialog[^]

Window.Open[^]
 
Share this answer
 
v5
Comments
rajanlive 29-Mar-12 23:25pm    
Thnx for reply and sharing some articles.I had some questionst to ask. how do i pass value from popup to parent? and what is the use of session "id" and ccode?
Bojjaiah 30-Mar-12 5:08am    
what ever you select value in childwindow that value to pass session so you can get childwindow value through session in parent window. first read the articles automatically you can know this or download article example to run the application you can know everything k.
rajanlive 30-Mar-12 9:08am    
thnx for your alternate solution...
Bojjaiah 30-Mar-12 9:35am    
Welcome :)
Member 13948079 4-Sep-19 1:42am    
saludos depronto tiene el codigo mas detallado es que no lo he realizado realiza gracias

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900