Click here to Skip to main content
16,018,394 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi i am linked the child aspx page with parent aspx page. when i click the button in parent aspx page the child aspx page opening. and when i click the OK button in the child aspx page, it has been closed no problem and now i want to pass the string value from the child aspx page (code behind) to parent aspx page textbox

How is possible?
Posted
Comments
ZurdoDev 22-Nov-13 21:14pm    
You'll need to post the relevant code. Are you talking about through a popup from JavaScript or are you Response.Redirecting in C#. Need more info.

Parent page.aspx
C#
protected void btn_Click(object sender, ImageClickEventArgs e)
   {

session["value"]=value.tosting();
}


child page.aspx
string empid="";

C#
protected void Page_Load(object sender, EventArgs e)
   {
       if (Session["value"].ToString() != "")
       {
           empid = Session["value"].ToString();

label.text=empid.tostring();
       }

}
 
Share this answer
 
Hi, Try this code..
its working based on javascript....



Parent page :

XML
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="jquery.js.js"></script>
    <script type="text/javascript">

        var openchild = function ()
        {

            window.open('childpage.aspx', 'popup_window', 'width=300,height=100,left=100,top=100,resizable=yes');
            return false;
        }


    </script>


</head>
<body>
    <form id="form1" runat="server">

        <table>
            <tr>
                <td>parent textbox</td>
                <td>
                    <asp:TextBox ID="txtparent" runat="server"></asp:TextBox></td>
            </tr>


            <tr>

                <td colspan="2" align="center">
                    <asp:Button  ID="btnSearch" OnClientClick="return openchild()" runat="server" Text="open child"  /></td>
            </tr>
        </table>


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





__________________________________________________________________________________________________
child page




XML
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="childpage.aspx.cs" Inherits="WebApplication1.childpage" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">

        var closechild = function () {

            var value = document.getElementById('txtchild').value;
            window.opener.document. getElementById('txtparent').value = value;
            window.close();

            return false;}


    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>

        <table>
            <tr>
                <td>child textbox</td>
                <td>
                    <asp:TextBox ID="txtchild" runat="server"></asp:TextBox></td>
            </tr>


            <tr>

                <td colspan="2" align="center">
                    <asp:Button  ID="btnclose" OnClientClick="return closechild()" runat="server" Text="close child"  /></td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>
 
Share this answer
 
Check these links:
Link 1[^]
Link 2[^]
Link 3[^]
Link 4[^]
Link 5[^]
Link 6[^]
 
Share this answer
 
Comments
King Fisher 22-Nov-13 23:48pm    
jas24

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