/    Sign up×
Community /Pin to ProfileBookmark

passing popup window value to the parent window is not worki

Hi,
I am trying to pass a textbox value from a popup window to the parent window textbox.

My parent window HTML looks like ,

<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”Default.aspx.cs” Inherits=”_Default” %>

<!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” type=”text/javascript”>

function GetValueFromChild(myVal)

{

var ddl= document.getElementById(“DropDownList1”);
var opt = document.createElement(“option”);
opt.text=myVal;
ddl.options[ddl.options.length].add(opt);

}

</script>

</head>
<body>
<form id=”form1″ runat=”server” >
<div>

<asp:TextBox ID=”TextBox1″ runat=”server” Style=”z-index: 104; left: 385px; position: absolute;
top: 358px”>default text</asp:TextBox>

</div>
</form>

</body>
</html>

My Popup page looks like ,
<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”AddCompany.aspx.cs” Inherits=”AddCompany” %>

<!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>Add New Company</title>
<script type=”text/javascript”>

function SetValueInParent()

{

window.opener.document.getElementByID(“TextBox1”).value= document.getElementById(<% = txt1.ClientID %>).value;
window.close();
return false;

}

</script>

</head>
<body>
<form id=”form1″ runat=”server”>
<div>
<h2>Add A New Company:</h2>
<br /><br />
Enter Company Name: &nbsp&nbsp&nbsp<asp:TextBox ID=”txt1″ runat=”server” /><asp:Button ID=”button1″ runat=”server” Text=”Save” OnClick=”button1_Click” OnClientClick=”javascript:returnSetValueInParent()”/> </div>
</form>
</body>
</html>

But when I am clicking the popup page button, the value frm the popup paeg is not getting populated in the parent page.

I could not find the reason.

Any reply will be appriciated.It is a kind of urgent.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@mintedjoNov 26.2008 — Shot in the dark...

Put a space after the word 'return'
Copy linkTweet thisAlerts:
@joydeep_sen157authorNov 26.2008 — yep...i have done that and got the correct result.

Thank you very much for your reply.
×

Success!

Help @joydeep_sen157 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...