0

problem:
On the parent page, I have a textfield and an image icon.on clicking the image, a popup (child) should open. The child form has a textbox ,a listbox and a button Go. By default, the listbox should be populated with employee names. When the user types a letter, the appropriate list item should be highlighted . On selecting an item and clicking GO button, the employee id of the selected name should appear in the parent form .

here is the code. I am using Vista, though no errors seem to be cropping, the popup does not occur.

parent.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Parent.aspx.cs" Inherits="Parent" %>

<!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>Untitled Page</title>
    <script type="text/javascript">
function openPopUp()
{
 var popUrl = 'Child.aspx';
 var name = 'popUp';
 var appearence ='dependent=yes,menubar=no,resizable=no,'+
                 'status=no,toolbar=no,titlebar=no,' +
                 'left=5,top=280,width=230px,height=140px';
var openWindow = window.open(popUrl, name, appearence);
openWindow.focus();
}
</script>
</head>
<body>
    <form id="f1" runat="server">
    <div>
        <asp:ImageButton ID="ImageButton1" runat="server" OnClick="ImageButton1_Click" style="z-index: 100; left: 284px; position: absolute; top: 33px" />
        <asp:TextBox ID="TextBox1" runat="server" Style="z-index: 102; left: 102px; position: absolute;
            top: 36px"></asp:TextBox>
    </div>
    </form>
</body>
</html>

Codebehind - parent.aspx
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Parent : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {


        if (!IsPostBack)
        {
          this .ImageButton1.Attributes.Add("onclick", "openPopUp('Cd.aspx')");
        }
       

    }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {

    }
}


child.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Child.aspx.cs" Inherits="Child" %>

<!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>Untitled Page</title>
    <script language="javascript">
        function GetRowValue()
        {
        
            window.opener.f1.TextBox1.value=document.form1.lst  Item.value;
            window.close ();
            }
     </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="txtList" runat="server"></asp:TextBox>
        <asp:Button ID="btngo" runat="server" OnClick="btngo_Click" Text="Go" /><br />
        <br />
        <asp:ListBox ID="lstItem" runat="server" AutoPostBack="True" OnSelectedIndexChanged="lstItem_SelectedIndexChanged"></asp:ListBox>&nbsp;
        <br />
        </div>
    </form>
</body>
</html>


codebehind - child.aspx
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using Sample;

public partial class Child : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            Logic obj = new Logic();
            string str = "select zone_name from zone_details";
            DataSet ds = obj.getDataSet(str);
            lstItem.DataSource = ds;
            lstItem.DataTextField = "zone_name";
            lstItem.DataBind();
        }

        this.lstItem.Attributes.Add("onclick", "GetRowValue()");


    }
    protected void btngo_Click(object sender, EventArgs e)
    {
        //Logic obj = new Logic();
        //string str = "select zone_name from zone_details where zone_name='"+txtList .Text +"'";
        //DataSet ds = obj.getDataSet(str);
        
    }
    protected void lstItem_SelectedIndexChanged(object sender, EventArgs e)
    {
        
    }
   
}


I have created a namespace 'Sample' used in the above code.

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

namespace Sample
{
    public class Logic
    {
        public DataSet getDataSet(string strsql)
        {
            string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
            SqlConnection con = new SqlConnection(constr);
            SqlCommand cmd = new SqlCommand(strsql , con);
            try
            {
                con.Open();
                SqlDataAdapter ad = new SqlDataAdapter(cmd);
                DataSet ds = new DataSet();
                ad.Fill(ds);
                return ds;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                con.Close();
                cmd.Dispose();
                con.Dispose();
            }
        }
    }
}
2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by __avd
0

Try out this,

...
function GetRowValue() {
   window.opener.document.getElementById("TextBox1").value = document.getElementById("lstItem").value;
   window.close();
}
...
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.