Click here to Skip to main content
11,480,626 members (62,232 online)
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 7: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 Sergey Alexandrovich Kryukov 294
1 OriginalGriff 155
2 Richard MacCutchan 150
3 CHill60 130
4 CPallini 125
0 Sergey Alexandrovich Kryukov 8,184
1 OriginalGriff 7,556
2 Sascha Lefèvre 3,114
3 Maciej Los 2,491
4 Richard Deeming 2,335


Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 29 Mar 2012
Copyright © CodeProject, 1999-2015
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