Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all,

I am trying that following on : 

https://www.aspsnippets.com/Articles/Pass-value-from-child-popup-window-to-parent-page-window-using-JavaScript.aspx

And it work fine.

But when using parent page had master page.

Javascrip error, can not get value.

 window.opener.document.getElementById("lblConfirm_Email").value = UserEmail;

lblConfirm_Email is textbox on Parent page
Popup use Gridview -> click row -> pass value to parent page.

So pls kindly help fix that.

Thanks so much

Nguyen Hien

What I have tried:

<pre lang="HTML">
<pre>function GetSelectedRow(lnk) {  
                if (window.opener != null && !window.opener.closed) {
                    var row = lnk.parentNode.parentNode;
                    var rowIndex = row.rowIndex - 1;
                    var UserEmail = row.cells[3].innerHTML;
                    var UserName = row.cells[2].innerHTML;
                    var parent_ID = getQueryVariable("ParentID");
                    //var Email1 = lblAppr_Email.ClientID.toString();
                    //var Name1 = lblAppr_Name.ClientID.toString();
                    if (parent_ID == "Appr") {
                        window.opener.document.getElementById("lblAppr_Name").value = UserName;
                        window.opener.document.getElementById("lblAppr_Email").value = UserEmail;
                    }



ASP.NET
<pre> <form id="form1" runat="server">
        <div id="Grid" style="overflow:auto;">
            <asp:GridView ID="GridView1"  runat="server" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3" OnRowCreated="RowCreated_report" OnRowDataBound = "OnRowDataBound"   >
                
                <FooterStyle BackColor="White" ForeColor="#000066" />
                <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
                <RowStyle ForeColor="#000066" />
                <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
                <SortedAscendingCellStyle BackColor="#F1F1F1" />
                <SortedAscendingHeaderStyle BackColor="#007DBB" />
                <SortedDescendingCellStyle BackColor="#CAC9C9" />
                <SortedDescendingHeaderStyle BackColor="#00547E" />
                <Columns>
                    <asp:TemplateField HeaderText="">
                        <ItemTemplate>
                            <asp:LinkButton ID="lnkSelect" runat="server" Text="Select" CommandName="Select" OnClientClick="return GetSelectedRow(this)"> </asp:LinkButton>
                           
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
            <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

        </div>
    </form>



And this is label on parent page(use master page):
ASP.NET
<pre><td class="auto-style4">
                        <asp:Label ID="lbappr" runat="server"></asp:Label>
                        <input  type="hidden" id="lblAppr_Email" runat="server" readonly="readonly" />
                        <input id="lblAppr_Name" type="text" readonly="readonly" runat="server"  />
                        <br />
                        <%--<asp:Button ID="Button4" runat="server" Text="Change" />--%>
                         <input type="button" value="Change" onclick="SelectDetails_appr()" />
                    </td>
Posted
Updated 26-Feb-19 17:56pm
v3
Comments
j snooze 27-Feb-19 17:13pm    
This makes sense. From what code is posted, I don't see an html control or any control named lblConfirm_Email on the parent page html you posted.
j snooze 27-Feb-19 17:15pm    
Also keep in mind if this label is an asp.net control label, sometimes on master/child pages asp.net changes the id to make sure they are unique between pages, when looking at your page in a browser do a right click > view source on the browser and find the lblConfirm_Email label in the actual HTML that asp.net outputs, the label may be renamed with extra characters to make it unique so the master and detail page don't run into issues.

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



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