Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET Javascript
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:
function open_child()
  {
  window.open("child.aspx");
  }
 
Child page:
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 29-Mar-12 6:25am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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[^]
  Permalink  
v5
Comments
rajanlive at 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 at 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 at 30-Mar-12 9:08am
   
thnx for your alternate solution...
Bojjaiah at 30-Mar-12 9:35am
   
Welcome :)

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

  Print Answers RSS
0 CPallini 345
1 BillWoodruff 324
2 George Jonsson 279
3 Sergey Alexandrovich Kryukov 258
4 OriginalGriff 227
0 OriginalGriff 5,050
1 CPallini 4,225
2 Sergey Alexandrovich Kryukov 3,639
3 George Jonsson 2,911
4 Gihan Liyanage 2,386


Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 29 Mar 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100