Click here to Skip to main content
14,298,696 members
Rate this:
Please Sign up or sign in to vote.
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 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()

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!

1 solution

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

Solution 1

try this in ok button event
//this is when u taken popup as normal ( 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


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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100