HI jkofte
Thanks for the reply - but if you read the last part of my post, you will see that I specifically state that I don't want to use CssClass.
Main Topics
Browse All TopicsHi
I am hitting a brick wall when it comes to working with asp.NET controls and external style sheets.
I have an external stylesheet called 'styles.css' which has a definition for #logo{...}
In my ASP.Net page, I have the following code:
<asp:Image runat=server src="<%=GlobalsManager.sit
but when the HTML is generated, the output is:
<img id="ctl00_logo" src="logo.gif" />
As you can see, the id is now "ct100_logo" instead of "logo"
I understand why this happens, due to the wrapper content and master pages.
What I would like to know is how do people get around this? I obviously don't want to prefix all my css classes with "Ct100" e.g. "#ct100_logo". I know that you can use the cssClass property to style it, but I would like to know how to use existing styles that are defined in an id css declaration, for example:
#logo
{
float:right;
border:1px solid black;
}
I really want to use "#logo" and not ".logo" (id instead of class).
What are the ways people use to handle this scenario?
Thanks
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi guys
Thanks for the responses.
I AM currently using an html image tag :)
The reason why i want to use an ASP:image is so that I can set its source via the code behind page.
BUT, I would like it to retain the css as described by its ID as I have a whole lot of pre-existing styles within a style sheet that I don't want to have to convert to classes (i.e. from #logo to .logo)
Also - to me it is incorrect to make the image styles use a CLASS instead if an ID, as classes are for styles that get used repeatedly and id's for unique elements, which this image is.
:)
Thanks
Well you can always use an html image, when you want to change it's source you can loop through the controls on the page
foreach (Control c in this.Controls)
{
if (c is System.Web.UI.HtmlControls
{
System.Web.UI.HtmlControls
hc.Attributes["src"] = "http://myimageSource.jpg"
}
}
Well actually I was wrong, because for blunt HTML tags it's a "LiteralControl" and not an html control so you would completely have to replace the HTML e.g.:
foreach (Control c in this.Controls)
{
if (c is LiteralControl)
{
LiteralControl hc = c as LiteralControl;
hc.Text = "<img src=\"http://myimageSource
}
}
If you don't want to do that then you have to convert it to a class.
Business Accounts
Answer for Membership
by: jkoftePosted on 2009-11-03 at 01:47:48ID: 25727325
serverside components also get container's name when getting client side Ids. FolderImag es %>/logo.gif" id="logo" />
you can use
<asp:Image CssClass="logo" runat=server src="<%=GlobalsManager.site
and for asp.net code
.logo
{
float:right;
border:1px solid black;
}
for css code.