Passing a value from a pop-up window to parent window in asp.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Robert Carlson
    New Member
    • Oct 2010
    • 1

    Passing a value from a pop-up window to parent window in asp.net

    My pop-up Window has this in a button click event:

    Code:
    string scriptString = "<script>JavaScript:window.opener.document.Form1.totalField.value =" + dNewTotalDue + "; JavaScript:window.opener.document.Form1.redeemField.value =" + dRedeemAmount + "; window.close();</script>";
    Page.RegisterStartupScript("Close", scriptString);
    The variables: dNewTotalDue & dRedeemAmount are doubles

    My Parent Window has this in a button click event:

    Code:
    Page.RegisterStartupScript("RedeemCard", "<script>JavaScript:window.open('" + redeemHwndUrl + "', 'RedeemCard', 'width=600,height=600,top=30,left=30,toolbars=no,scrollbars=no,status=no,resizable=no');</script>");

    This all worked fine when I was using an html page as the Parent window. But it stopped working when I decided to use an asp.net page as the parent window.

    I also switched from using and html <input type="text"...> textbox to: <asp:textbox id="totalField " runat="server" Width="80px" MaxLength="20"> </asp:textbox>

    The pop-up works fine and I can pas values from the Parent to the pop-up. But when I click on the child window button, it does nothing. The pop-up does not close and the Parent window fields do not get populated with the dNewTotalDue & dRedeemAmount varaible values.

    Any help would be much appreciated!
    Last edited by Niheel; Oct 2 '10, 06:46 PM.
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    ASP.NET will probably be changing the id when it generates the text field. So,
    - either check the source to see what the totalField ID looks like and use that instead,
    - or you could use the ClientID property from ASP.NET to generate the JavaScript (probably the preferred option).

    If you get stuck with the ASP.NET part, you can ask in the ASP.NET forum.

    Comment

    Working...