Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7039579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:48:56+00:00 2026-05-28T01:48:56+00:00

I have 2 pages, Cart.aspx and SelectPartner.aspx. And a JavaScript file, popup.js In Cart.aspx

  • 0

I have 2 pages, Cart.aspx and SelectPartner.aspx. And a JavaScript file, popup.js

In Cart.aspx I have a button that opens the page SelectPartner.aspx (as a new window) by the InvokePop() function.

In SelectPartner.aspx I have a gridview (with Selection enabled), a textbox, and buttons Ok and Cancel. This is what I want to do: when I select an item in the gridview, the value of one column is shown in the textbox, and when when I press the button Ok the function ReturnPartner() is called and should close the this window (SelectPartner.aspx) and show the value of this textbox in another textbox in the Cart.aspx page. If I write something into the TextBox in SelectPartner.aspx I can pass that value to the TextBox in the Cart.aspx page, but when I press a select button in the gridview the value is not passed.

I don’t know what happens, please help me…

Here is the code of Cart.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Cart.aspx.cs" Inherits="NMv01.Cart" %>
<%@ Register TagPrefix="asp" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit"%>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
        #Select1
        {
            height: 16px;
            width: 24px;
        }
    </style>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript" src="popup.js"></script>
    <asp:Label ID="lblPartnerId" runat="server" Text="ID del Socio"></asp:Label>
                <br />
                <asp:TextBox ID="txtPartnerID" runat="server"></asp:TextBox>
                &nbsp;&nbsp;<asp:Button ID="btnPartnerId" runat="server" Text="Elegir Socio" />
                &nbsp;


</asp:Content>

Now SelectPartner.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SelectPartner.aspx.cs" Inherits="NMv01.catalog.SelectPartner" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" src="popup.js"></script>
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>

        <table class="style1">
            <tr>
                <td>
                    &nbsp;</td>
                <td>
                    <asp:GridView ID="grdSelectPartner" runat="server" AutoGenerateColumns="False" 
                        AutoGenerateSelectButton="True" DataKeyNames="PartnerId" 
                        DataSourceID="srcSelectPartner" 
                        onselectedindexchanged="grdSelectPartner_SelectedIndexChanged">
                        <Columns>
                            <asp:BoundField DataField="PartnerName" HeaderText="PartnerName" 
                                SortExpression="PartnerName" />
                            <asp:BoundField DataField="PartnerId" HeaderText="PartnerId" ReadOnly="True" 
                                SortExpression="PartnerId" />
                            <asp:BoundField DataField="PartnerCity" HeaderText="PartnerCity" 
                                SortExpression="PartnerCity" />
                        </Columns>
                    </asp:GridView>
                    <asp:SqlDataSource ID="srcSelectPartner" runat="server" 
                        ConnectionString="Data Source=ZUNIGA-PC\SQL1;Initial Catalog=NovamMonetanDB;User ID=sa; pwd=Next2011" 
                        ProviderName="System.Data.SqlClient" 

                        SelectCommand="SELECT [PartnerName], [PartnerId], [PartnerCity] FROM [Partners] ORDER BY [PartnerName]">
                    </asp:SqlDataSource>
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    &nbsp;</td>
                <td>
                    <asp:Label ID="Label1" runat="server" Text="ID:"></asp:Label>
                    &nbsp;<asp:TextBox ID="txtPartner" runat="server"></asp:TextBox>
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    &nbsp;</td>
                <td>
                    <asp:Button ID="btnOk" runat="server" Text="OK" OnClientClick="ReturnPartner()" />
                    &nbsp; <asp:Button ID="btnCancel" runat="server" Text="Cancelar" />
                    <br />
                    <br />
                </td>
                <td>
                    &nbsp;</td>
            </tr>
        </table>

    </div>
    </form>
</body>
</html>

And this is the popup.js file:

function InvokePop(fname) {
    val = document.getElementById(fname).value;
    // to handle in IE 7.0          
    if (window.showModalDialog) {
        retVal = window.showModalDialog("SelectPartner.aspx?Control1=" + fname, 'Choose Partner', "dialogHeight:360px,dialogWidth:360px,resizable:yes,center:yes,");
        document.getElementById(fname).value = retVal;
    }
    // to handle in Firefox
    else {
        retVal = window.open("SelectPartner.aspx?Control1=" + fname, 'Choose Partner', 'height=360px,width=360px,resizable=yes,modal=yes');
        retVal.focus();
    }
}


function ReturnPartner() {
    var returnString = document.getElementById('txtPartner').value;
    RetrieveControl();
    // to handle in IE 7.0
    if (window.showModalDialog) {
        window.returnValue = returnString;
        window.close();
    }
    // to handle in Firefox
    else {
        if ((window.opener != null) && (!window.opener.closed)) {
            // Access the control.       
            window.opener.document.getElementById(ctr[1]).value = returnString;
        }
        window.close();
    }
}

function RetrieveControl() {
    //Retrieve the query string
    queryStr = window.location.search.substring(1);
    //Retrieve the control passed via querystring
    ctr = queryStr.split("=");
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:48:56+00:00Added an answer on May 28, 2026 at 1:48 am

    I would suggest you to remove the use of window.showModalDialog() and use window.open() instead because Window.open() is supported uniformly by all browsers while window.ShowModalDialog() is an MSIE feature only.

    showModalDialog() is said to have trouble “posting back” for which a iframe hack is needed.

    i tested your code with window.open for all browsers and it worked great.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a shopping cart page (Cart.aspx) that has a button that will (sometimes)
I have a simple cart page that displays items that are in someones cart,
I have some pages on my site that are plain HTML pages, but I
I have several pages to do with several table on each page. I've got
I have a Pages table that stores all my view urls and this table
I have some pages that I don't want users to be able to access
I have two pages, NonMember.aspx and Member.aspx. If a user comes to the site,
I have the pages that I want to set as a goal in Google
I have some pages on my public website that display charts generated by ASP.NET
I have a situation with my MVC2 app where I have multiple pages that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.