469,269 Members | 1,006 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,269 developers. It's quick & easy.

modal form javascript can't find server control in opener to paste

I have a web form “Form1” with a panel. Inside the panel is a datalist. One
of the items displays the field value “xyz” from the dataset. If the field
is null the user clicks on a javascript to let him pick a value for the field
from a popup modal window.

<td><a href="javascript:GetNet()"> <img src="”> </a>VPN Network:</td>

<% if (XYZ !=""){%>
<td><asp:TextBox id="txtXYZ" runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "XYZ") %>'></asp:TextBox>
<%}else{%>
<input type="text" runat=server id="XYZ">
<%}%></td>

The javascript on modal form tries to put a value selected back into
form1.XYZ with

function pasteNet(lstr)
{
window.opener.document.forms["Form1"].elements["XYZ"].value = lstr;
window.close();
}
I get the error

Microsoft JScript runtime error:
'window.opener.document.forms.Form1.elements.vpnne t' is null or not an object

Is the syntax for identifying the server control input box incorrect? Does
it have to do with the input box being nested in the “if statement”. If I
use an html input box it works fine, the problem I need to attach code to the
input box so server control.

Please help
cindy
Nov 19 '05 #1
3 5230
Cindy,

I like using document.getElementById('[ElementName]') to find page items via
javascript.

Try:

function pasteNet(lstr)
{
window.opener.document.getElementById('XYZ').value = lstr;
window.close();
}

If that doesn't work you may need to check how you're referring to
window.opener.
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"cindy" <cm****@nospam.nospam> wrote in message
news:86**********************************@microsof t.com...
I have a web form "Form1" with a panel. Inside the panel is a datalist.
One
of the items displays the field value "xyz" from the dataset. If the
field
is null the user clicks on a javascript to let him pick a value for the
field
from a popup modal window.

<td><a href="javascript:GetNet()"> <img src=""> </a>VPN Network:</td>

<% if (XYZ !=""){%>
<td><asp:TextBox id="txtXYZ" runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "XYZ") %>'></asp:TextBox>
<%}else{%>
<input type="text" runat=server id="XYZ">
<%}%></td>

The javascript on modal form tries to put a value selected back into
form1.XYZ with

function pasteNet(lstr)
{
window.opener.document.forms["Form1"].elements["XYZ"].value = lstr;
window.close();
}
I get the error

Microsoft JScript runtime error:
'window.opener.document.forms.Form1.elements.vpnne t' is null or not an
object

Is the syntax for identifying the server control input box incorrect?
Does
it have to do with the input box being nested in the "if statement". If I
use an html input box it works fine, the problem I need to attach code to
the
input box so server control.

Please help
cindy

Nov 19 '05 #2
the best way to start debugging this is to view source HTML and check
if the control exists with the name you are trying to refer ..

Also following may help..

it would be easier to use the 'returnValue' from modal window,when you
need to return only 1 value

open modal window like
var str = window.showModalDialog(" ....
if (str != "")
window.opener.document.forms["Form1"].elements["XYZ"].value = str
Assign window.returnValue = lstr from the popup

Nov 19 '05 #3
if the textbox is a child of another control (say a repeater), then its
rendered name and id will have the parents prepended with a seperator. you
can use the ClientId property to get the fully qualified id, but the name is
not supported.
-- bruce (sqlwork.com)
"cindy" <cm****@nospam.nospam> wrote in message
news:86**********************************@microsof t.com...
I have a web form "Form1" with a panel. Inside the panel is a datalist.
One
of the items displays the field value "xyz" from the dataset. If the
field
is null the user clicks on a javascript to let him pick a value for the
field
from a popup modal window.

<td><a href="javascript:GetNet()"> <img src=""> </a>VPN Network:</td>

<% if (XYZ !=""){%>
<td><asp:TextBox id="txtXYZ" runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "XYZ") %>'></asp:TextBox>
<%}else{%>
<input type="text" runat=server id="XYZ">
<%}%></td>

The javascript on modal form tries to put a value selected back into
form1.XYZ with

function pasteNet(lstr)
{
window.opener.document.forms["Form1"].elements["XYZ"].value = lstr;
window.close();
}
I get the error

Microsoft JScript runtime error:
'window.opener.document.forms.Form1.elements.vpnne t' is null or not an
object

Is the syntax for identifying the server control input box incorrect?
Does
it have to do with the input box being nested in the "if statement". If I
use an html input box it works fine, the problem I need to attach code to
the
input box so server control.

Please help
cindy

Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by William Starr Moake | last post: by
1 post views Thread by stellabein | last post: by
4 posts views Thread by Brian Henry | last post: by
8 posts views Thread by tshad | last post: by
4 posts views Thread by Hitesh | last post: by
2 posts views Thread by sthrudel | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.