ascx changes input id

  • Thread starter Thread starter Leon Chuck Gosslin
  • Start date Start date
L

Leon Chuck Gosslin

When using an ascx page, I use a textbox input as follows

<asp:TextBox id="txtDate" runat="server" Width="130px"></asp:TextBox

I want to use javascript to access this textbox, but when it posts to a browser, it gives some wierd id to the textbox, like

<input name="_ctl0:txtDate" type="text" id="_ctl0_txtDate" style="width:130px;" /

So is there anyway to access this field from javascript

Thanks

Leon.
 
This is so that if you have 2 of the user control on a page, that all the
HTML elements still have unique ID's.

So, you should use the ClientID property on the server side to get this
name.You then might have to emit it into your javascript in the right spots,
in order to be able to use it.
 
Back
Top