Click here to Skip to main content
12,509,899 members (52,457 online)
Rate this:
Please Sign up or sign in to vote.
See more: ASP.NET Javascript
I have a javascript function in which if a user select future date then a pop up will appear and that pop up will contain an text box and a button.The user enter the value in the text box and click on the Button of child pop up.I want to capture those value in the parent window but i m not able to do it.

Below is the javascript which i had written:-
function CheckDateEalier(sender, args)
            var toDate = new Date();
            if (sender._selectedDate < toDate)
                alert("You can't select day earlier than today! In Case if you are selecting Previous date then, By default it will take current Date.");
                sender._selectedDate = toDate;
                //set the date back to the current date
            if (sender._selectedDate > toDate) {
                var timeSpent ="EnterTimeSpent.aspx", "List", "scrollbars=no,resizable=no,width=320,height=100");
                document.getElementById('<%=hiddenFieldFutureDateSelectTimeSpent.ClientID %>').value = timeSpent;
                return false;
ASP Code for Child page:-
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="EnterTimeSpent.aspx.cs" Inherits="EmployeeQuotient.EnterTimeSpent" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
    <link href="CSS/buttons.css" rel="stylesheet" type="text/css" />
    <title>Enter Time Spent</title>
<script language="javascript" type="text/javascript">
    <form id="form1" runat="server">
        <asp:Label ID="Label1" runat="server" Text="Time Spent : " Font-Bold="True" 
            Font-Italic="False" Font-Names="Times New Roman" Font-Size="Small" 
        <asp:TextBox ID="txtTimeSpent" runat="server"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtTimeSpent" ErrorMessage="Field Cant be left blank." Font-Size="X-Small" ForeColor="Red"></asp:RequiredFieldValidator><br />
        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"  ControlToValidate="txtTimeSpent" ValidationExpression="^\d+$" ErrorMessage="Only Numeric with non decimal allowed"  Font-Size="X-Small" ForeColor="Red"></asp:RegularExpressionValidator></td>
        <asp:Button ID="btnSubmitTimeSpent" runat="server" Text="Submit" CssClass="button small green rounded" OnClientClick="btnSubmitTimeSpent()"/></td></tr>
Please help me that how i pass those value from child to parent from javascript and page will close as user click on the button, currently when i m clicking on button again a modal pop up is appearing and then i have to manually close the page.
Posted 30-May-12 21:54pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

add a TextBox on your parent page as

<asp:textbox id="Txtparent" runat="Server" xmlns:asp="#unknown" />
and set its value from the child page as

window.opener.document.forms[0].getElementById('Txtparent').value ="Value From Popup Page";
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

You can also return the value on button click

function btnSubmitTimeSpent()

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.160929.1 | Last Updated 31 May 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100