Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it bad practice to assign a css class for the sole purpose of finding it with jQuery?

Tags:

jquery

asp.net

I'm using ASP.NET, not the newest one with that clientIdMode stuff. So, the control ids are generated and funky.

There are lots of ways of passing ids around, but lately I've been assigning a 'fake' css class to the control I'm interested in. Then in a js file I use jQuery to find the control.

Is this bad practice? It seems a lot like the ajaxControlToolkit's behaviorId to me... Is the behaviorId bad practice as well?

like image 545
internet man Avatar asked May 11 '10 20:05

internet man


1 Answers

It's a great way to do things; I've done this plenty. The auto-generated IDs suck, although if you leave the runat="server" off, you can use those too. (I know it's not always an option, but for when it is an option, you can do so).

like image 168
jvenema Avatar answered Nov 15 '22 05:11

jvenema