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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top