RunAt=Server renaming components

liptonIcedTea

Well-known member
Joined
Jan 18, 2007
Messages
89
Programming Experience
1-3
Hi,

I have a DIV in a page which appearance is half done by CSS (height, width etc.) and half specified by ASP.NET code (background etc.)

The problem is I have done this

<div id="divID" runat=server>

the runat=server changes the clientID of the component so that it no longer recognised by the CSS file.

Is there a way you can specify runat=server to not change the ID and to just use the ID specified for the div in the markup (id="divID")?
 
Unfortunately no, you can't. The IDs are really only designed to be use programmatically, and because you can have the same control in different containers, ASP.NET prefixes the container names and some other stuff to ensure that the IDs are unique.

I usually use the CssClass attribute to set a CSS class which defines the way that it should be displayed. I use CSS classes for pretty much everything. I've never found any real disadvantage of doing that over using CSS ID selectors except that it takes a few extra bytes to render the class attribute in the HTML, but I doubt that this is a major overhead for you.
 
Back
Top