Reputation: 83
I have a web application in VS 2008. I used jquery for validation of different Forms and used it for other purposes. In VS 2008 I get the IDs of page controls in jquery like Ctl001_.... , but now I have upgraded the application to VS 2010 and now all my page controls are giving error in jquery because its changed its ID there as ContentBody_....., I can not convert all these to the new prefix ContentBody_.... because on the server my project runs on .Net Framework 3.5 and there the IDs are with the Prefix of Ctl001_...., can any one tell me a way that I can easily get control's ID in jquery without depending on the .Net Framework.
any help would be greatly appreciated.
Upvotes: 0
Views: 1022
Reputation: 3412
You can use ends with selector: http://api.jquery.com/attribute-ends-with-selector/
jQuery('[id$="_textBox1"]');
Upvotes: 0
Reputation: 443
You should use the ClientID
property of the asp controls. $('#<%=textBox1.ClientID%>')
would return $('#ctl001_textBox1')
or whatever asp decides to rename it.
Upvotes: 2