User Controls and CSS

D

Dune88

Hi there,

I've got a user control that uses it's own CSS classes. At the moment, I've
put those CSS classes in the <head> section of the ASPX page containing the
user control.

Ideally, I'd like the user control specific CSS to live with the user
control so that the user control can be reused as one single unit. Also, if
there is more than one instance of the user control on the same page, the
user control specific CSS should only be emitted once.

Does anyone have any suggestions for how to achieve this? How is everyone
else handling this situation?

Cheers.
 
M

Masudur

Hi there,

I've got a user control that uses it's own CSS classes. At the moment, I've
put those CSS classes in the <head> section of the ASPX page containing the
user control.

Ideally, I'd like the user control specific CSS to live with the user
control so that the user control can be reused as one single unit. Also, if
there is more than one instance of the user control on the same page, the
user control specific CSS should only be emitted once.

Does anyone have any suggestions for how to achieve this? How is everyone
else handling this situation?

Cheers.

Hi,

you can develop a separate style sheet for usercontrol and and in
usercontrol link the style sheet...

<%@ Control Language="C#" AutoEventWireup="true"
CodeBehind="Footer.ascx.cs" Inherits="TME.UI.UserControls.Footer" %>
<link type="text/css" rel="Stylesheet" href="../App_Themes/Default/
default.css" />
<div>
</div>

but as u can see if multiple instance of user control placed in page
you got multiple style reference link...
gain to over come the problem you have to put this link in page ...
that is what you are doing now...

its pretty good..

But will suffer from few problem if you use theme based web site...

Thanks & Best of Luck
Md. Masudur Rahman
www.munna.shatkotha.com
www.munna.shatkotha.com/blog
www.shatkotha.com
 
G

gerry

We came up with a StyleSheetManager that functions similar to the
ScriptManager.
Each control registers required stylesheets with the StyleSheetManager which
in turns renders the appropriate markup to the page.
The manager handles embedded stylesheets , external stylesheets and external
embedded resource stylesheets.
Any given stylesheet is only included in the page once and all stylesheets
end up in the header section where they should be.
 
D

Dune88

Thanks for the suggestions, I'll give them a go.

gerry said:
We came up with a StyleSheetManager that functions similar to the
ScriptManager.
Each control registers required stylesheets with the StyleSheetManager which
in turns renders the appropriate markup to the page.
The manager handles embedded stylesheets , external stylesheets and external
embedded resource stylesheets.
Any given stylesheet is only included in the page once and all stylesheets
end up in the header section where they should be.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,817
Latest member
AdalbertoT

Latest Threads

Top