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

Discussion in 'ASP .Net' started by =?Utf-8?B?Y2luZHk=?=, Sep 15, 2005.

  1. 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.vpnnet' 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
    =?Utf-8?B?Y2luZHk=?=, Sep 15, 2005
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:...
    >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.vpnnet' 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
    S. Justin Gengo, Sep 15, 2005
    #2
    1. Advertising

  3. =?Utf-8?B?Y2luZHk=?=

    Guest

    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
    , Sep 15, 2005
    #3
  4. =?Utf-8?B?Y2luZHk=?=

    Bruce Barker Guest

    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" <> wrote in message
    news:...
    >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.vpnnet' 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
    Bruce Barker, Sep 16, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt
    Replies:
    1
    Views:
    3,136
    Whitecrest
    Jun 1, 2004
  2. Urs Gubler
    Replies:
    0
    Views:
    150
    Urs Gubler
    Jul 2, 2003
  3. Yaron C.

    opener.opener ?

    Yaron C., Oct 30, 2003, in forum: Javascript
    Replies:
    4
    Views:
    208
    Yaron C.
    Nov 2, 2003
  4. Matt
    Replies:
    0
    Views:
    217
  5. window.opener, form.opener?

    , Jul 14, 2006, in forum: Javascript
    Replies:
    5
    Views:
    279
Loading...

Share This Page