Can css be applied to controls of the page.aspx?
To anything and everything?
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.
Yes, and no.
You can’t style server controls, as they never reach the browser, but you can style the HTML code that is rendered from the controls.
The server controls in the .aspx source only exist on the server while rendering the page. What’s left of the controls when the page is sent to the browser is only the HTML code that the controls are rendered as. For example, a
TextBoxcontrol renders as aninputortextareaelement.You can use CSS to style the elements that the controls render, but for that you need something to target the element. You can for example specify a
CssClassvalue for a control which will be rendered as aclassattribute in the HTML code. Another alternative is to specify a class or an id on the surrounding element.The
IDof a server control is however not useful for targeting the elements in CSS. Whenever a control is within a container (like aPlaceHolderorRepeater), it’s identity is prepended with the container name to keep identities unique.