Click here to Skip to main content
Rate this: bad
good
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();
            toDate.setMinutes(0);
            toDate.setSeconds(0);
            toDate.setHours(0);
            toDate.setMilliseconds(0);
            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
                sender._textbox.set_Value(sender._selectedDate.format(sender._format))
            }
            if (sender._selectedDate > toDate) {
                var timeSpent = window.open("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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <link href="CSS/buttons.css" rel="stylesheet" type="text/css" />
    <title>Enter Time Spent</title>
</head>
<body>
<script language="javascript" type="text/javascript">
 
</script>
    <form id="form1" runat="server">
    <div>
    <table>
    <tr>
    <td>
        <asp:Label ID="Label1" runat="server" Text="Time Spent : " Font-Bold="True" 
            Font-Italic="False" Font-Names="Times New Roman" Font-Size="Small" 
            ForeColor="green"></asp:Label>
    </td>
    <td>
        <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>
    </tr>
    <tr>
    <td>
        <asp:Button ID="btnSubmitTimeSpent" runat="server" Text="Submit" CssClass="button small green rounded" OnClientClick="btnSubmitTimeSpent()"/></td></tr>
    </table>    
    </div>
    </form>
</body>
</html>
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 22:54pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

hi,
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";
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

You can also return the value on button click
 
function btnSubmitTimeSpent()
{
window.returnValue="time";
window.close();
}
  Permalink  

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



Advertise | Privacy | Mobile
Web02 | 2.8.141223.1 | Last Updated 31 May 2012
Copyright © CodeProject, 1999-2014
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