asp.net 2.0, control ids and clientID

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi

I have a simple master page and a simpel webform that uses this master
page

Inside the webform is a textbox, the id of the textbox is txt1.

Now on the client, I want to do some scripting using this textbox and
that means I need the id.

But the client id is something like ct00_ContentPlaceHolder1_txt1
Hmmm - not very friendly for a start not to mention its a bit long! Who
is the world would call a control that! (okay I called mine txt1 - but
at least thats obvious!)

My issue is -

1)This prefix will change according to the namingcontainer, has anybody
found an elegant way of working with the control on the client,
regardless of where the control resides. I mean I would like to say on
my client

var objTxt1=document.getElementById('txt1');

but I cant!

Whats the reccomended route to take here....

.



Relevant Pages

  • Re: asp.net 2.0, control ids and clientID
    ... I have a simple master page and a simpel webform that uses this master ... But the client id is something like ct00_ContentPlaceHolder1_txt1 ... found an elegant way of working with the control on the client, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Title Slide: Additional AutoLayouts?
    ... This is not an option in PPT, ... Click on it and draw a textbox on your slide (not the master). ... Click to add Client. ...
    (microsoft.public.powerpoint)
  • Re: Master Pages and Cross-Page Form Information
    ... > David R. Longnecker ... > Management Information Services ... >> | since we're using Master page, the textboxes are cotained in the ... >> | in that textbox. ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Re: Master Pages and Cross-Page Form Information
    ... > | As for the querying TextBox values from Previous page when doing cross ... > | since we're using Master page, the textboxes are cotained in the ... > | public string TextBox1Value ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • RE: Master Pages and Cross-Page Form Information
    ... As for the querying TextBox values from Previous page when doing cross page ... since we're using Master page, the textboxes are cotained in the ... Previous for cross page postback is defining some public Properties in the ... public string TextBox1Value ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)