Is it possible to use css with controls that generate ClientID and not regular ID?
I now I can use cssClass, but i want to know if it’s possilbe to use id’s:
#DivParrentId #LAbelControlId
{
padding:100px;
color:Red;
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There’s not a good way to do this. Many developers use something like this:
But frankly I am not a big fan of it. It’s very tag-soupy and fragile. Starting with ASP.NET 4.0, you will be able to control the ClientID of an element in code, so you can specify IDs for elements you know you will need to target with CSS or JS.
In the meantime, I recommend using classes. In the system I work on, we require classes and ban IDs for any client-side code (CSS or JS) because it’s just not worth the extra overhead. Classes can work just fine as IDs – nothing stopping you from having many unique (one-use) classes, and there’s no real issue with working this way from a maintainability standpoint.