Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using a css with .net 1

Status
Not open for further replies.

Kalisto

Programmer
Feb 18, 2003
997
GB
I hacve a basic aspx page that loads in a web control (ascx)

Is there any way I can associate the ascx with a css?
If so, how, do i need to have the css on the main page, or on the control. (or can I not use a css on a web control like this ?)

K
 
If the css is in the containing page it will be applied to all elements in the control.

You could write a <link href=.... /> tag into your ascx page if you only wanted it to be applied when the user contrl was included in the page, but this would produce invalid html because the linktag should only appear in the head of the document.

If your bothered about this (like me) then you could make the <head> of the page a HtmlGenericControl. Look up through the control hierarchy to the page, find the head control and add the link to it as a literal. Bit of a phaff though, it just depends on wether non-standards compliant HTML will keep you up at night ;-)

I think there is a real requirement for a Page.RegisterClientStyleSheet method a bit like Page.RegisterClientScript to handle this for you. Haven't heard of it for 2005 though so I guess its just wishful thinking....

Rob

Go placidly amidst the noise and haste, and remember what peace there may be in silence - Erhmann 1927
 
Unfortunately, I have to be bothered because of the person I am aiming the site at, so can you elaborate ?
 
Just use standard techniques, as you would with any other HTML page. Use:

<link rel="stylesheet" type="text/css" href="myStyle.css" />

in the <head> section of your page.



Thomas D. Greer

Providing PostScript & PDF
Training, Development & Consulting


If this post was helpful, click some ads! My personal site is also advertiser-supported. Hint, hint!
 
God, this thread is so old Id forgotten about it !
I think (like most problems on here, that there was a typo invovled somewhere..)

K
 
i've tried putting <link rel="stylesheet" type="text/css" href="myStyle.css" />

into my header1.ascx page but it's not doing anything.
i put it <head></head> tags around it but when i hop from code view to design view back to code view it takes the <link ... out of and just below the Head tags

i know i am stupid, but what am i doing wrong here.

LikeThisName <- ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top