Can css be applied to controls of the page.aspx?
To anything and everything?
Can css be applied to controls of the page.aspx?
To anything and everything?
You may also want to consider Themes and Skins for asp.net.
Otherwise use the CssClass
property on the control.
<asp:Button ID="Button1" CssClass="CSS_class_here" runat="server" Text="Click me" />
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 TextBox
control renders as an input
or textarea
element.
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 CssClass
value for a control which will be rendered as a class
attribute in the HTML code. Another alternative is to specify a class or an id on the surrounding element.
The ID
of a server control is however not useful for targeting the elements in CSS. Whenever a control is within a container (like a PlaceHolder
or Repeater
), it's identity is prepended with the container name to keep identities unique.