Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

User Controls and CSS

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dune88 - 19 Mar 2008 04:28 GMT
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.
Masudur - 19 Mar 2008 11:23 GMT
> Hi there,
>
[quoted text clipped - 11 lines]
>
> 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
gerry - 19 Mar 2008 14:37 GMT
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.

> Hi there,
>
[quoted text clipped - 14 lines]
>
> Cheers.
Dune88 - 25 Mar 2008 01:35 GMT
Thanks for the suggestions, I'll give them a go.

> We came up with a StyleSheetManager that functions similar to the
> ScriptManager.
[quoted text clipped - 23 lines]
> >
> > Cheers.
marss - 25 Mar 2008 08:18 GMT
> Does anyone have any suggestions for how to achieve this? How is everyone
> else handling this situation?
>
> Cheers.

Here is my approach to runtime stylesheet registration, maybe it will
be useful for you:
http://marss.co.ua/StylesheetRegistration.aspx

Regards,
Mykola

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.