Obtaining element ID for client script

Discussion in 'ASP .Net Web Controls' started by kw, Aug 23, 2004.

  1. kw

    kw Guest

    What is the proper way to get the element ID for a client script?

    For example, suppose in the WebControl:
    TextBox t=new TextBox;
    t.ID=this.ClientID+"X";
    ....
    Then elsewhere we want to access it on the client:
    Control.Attributes["OnClick"] =
    "javascript:document.getElementById('"+this.ClientID+"X"+"').value=
    'test';";

    It doesn't work because the textbox ID becomes something like:

    TextBox1_X

    and the link control looks like this:

    javascript:document.getElementById('TextBox1X').value= 'test';
     
    kw, Aug 23, 2004
    #1
    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. Roberto
    Replies:
    4
    Views:
    4,979
    hbasavar
    Mar 26, 2010
  2. Replies:
    10
    Views:
    977
    Robert Maas, see http://tinyurl.com/uh3t
    May 15, 2005
  3. =?ISO-8859-1?Q?Ney_Andr=E9_de_Mello_Zunino?=

    Obtaining the position of an element with a collection

    =?ISO-8859-1?Q?Ney_Andr=E9_de_Mello_Zunino?=, Oct 24, 2004, in forum: C++
    Replies:
    2
    Views:
    379
    Ioannis Vranos
    Oct 24, 2004
  4. HANM
    Replies:
    2
    Views:
    723
    Joseph Kesselman
    Jan 29, 2008
  5. What-a-Tool

    Method for obtaining client display size?

    What-a-Tool, Jan 4, 2005, in forum: ASP General
    Replies:
    4
    Views:
    165
    What-a-Tool
    Jan 4, 2005
Loading...

Share This Page