CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 3/30/2007 11:22:45 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 3 Views: 30 Favorited: 0 Favorite
4 Items, 1 Pages 1 |< << Go >> >|
csdietrich
Asp.Net User
Themes includes all CSS files3/30/2007 11:22:45 PM

0

I have a situation where I have two Master Pages. One of the master pages defines a single column layout. The other master page defines a two column layout. I have a total of 3 CSS files. One of the files contains global rules that apply to both master pages. The other two files are essentially incompatible with each other. One of them contains styles for the 'single column' layout. The other contains styles for the 'two column' layout. Unfortunately, when using Theming all CSS files are dumped out to the page. Therefore, the last file that gets linked wins out.

Is there any way to control the files that get sent to the browser? Or, is the only way I can accomplish this by turning off themes and manually adding the links myself? It would seem a shame to get rid of the feature.
 

aggiekevin
Asp.Net User
Re: Themes includes all CSS files3/31/2007 5:33:01 AM

0

Why not just create two separate themes, one for each layout. You can copy the the global css into each theme and each of the other two files into their respective themes.

thanks and gig 'em!

--aggiekevin|07--
csdietrich
Asp.Net User
Re: Themes includes all CSS files4/2/2007 4:12:37 PM

0

While what was suggested would definitely work I have a few problems with it. It certainly doesn't fit my perception of how Master Pages and Themes work. My thought is that Master Pages describe the structure of the content that most pages will share. While themes control the visual representation (colors, fonts, sizes, etc). The other problem is that if the customer requires some changes to be made to the style, then we need to first remember that we split the styles in two Themes and then make the changes in both of the files.

 I have given this issue some thought and have come up with the following ideas:

  1. Do as aggiekevin suggests and make two themes. Works but causes data duplication and breaks convention.
  2. Turn off Theming all together. Then insert whatever links I want to in the <head> portion of the master page. Problem with this is that we loose the usage of some 'skin' files. This might be acceptable.
  3. Override the Render of the Header controls. Find all links generated via ASP.NET and remove them. Ensure that manual links to Style Sheets in the header do not get removed.
  4. Rework the style sheets to contain "Context Sensitive Selectors" such that all rules can belong in one style sheet. The one downside to this is that it adds a little bit of CSS bloat, but might be acceptable.

What I mean by "Context Sensitive Selectors" is the following:

http://intensivstation.ch/en/css/selectors/ 

Anyway, if anyone has any thoughts on this please let me know.

Thanks. 

Adam.Kahtava
Asp.Net User
Re: Themes includes all CSS files4/2/2007 4:31:54 PM

0

Create a new class in your App_Code directory and copy the following code into your new class. Viola! You can now link CSS files into the HTML Head even with Themes turned on. Themes have a number of design flaws read more here: The Problems with Themes, Skins, and Cascading Style Sheets (CSS) - Where it all Falls Apart

This code was provided by David Marzo and will soon be published on my blog. Hope it helps.

The Code:

using System;
using System.Data;
using System.Security.Permissions;
using System.Web;
using System.Web.Caching;
using System.Web.Hosting;
using System.Collections;

namespace Arfila.Web.Logic
{
    //Excludes .css files from the App_Theme directory

    [AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Medium)]
    [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.High)]
    public class CustomVirtualPathProvider : VirtualPathProvider
    {
        public static void AppInitialize()
        {
            HostingEnvironment.RegisterVirtualPathProvider(new CustomVirtualPathProvider());
        } 

        public CustomVirtualPathProvider() : base() { }

        private bool IsThemeDirectory(string virtualPath)
        {
            String checkPath = VirtualPathUtility.ToAppRelative(virtualPath);
            return checkPath.StartsWith("~/App_Themes", StringComparison.InvariantCultureIgnoreCase);
        }

        public override VirtualDirectory GetDirectory(string virtualDir)
        {
            if (IsThemeDirectory(virtualDir))
            {
                return new ThemeDirectory(Previous.GetDirectory(virtualDir));
            }
            else
            {
                return Previous.GetDirectory(virtualDir);
            }
        }
    }

    [AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)]
    [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
    public class ThemeDirectory : VirtualDirectory
    {
        VirtualDirectory _toFilter;
        private ArrayList _children = new ArrayList();
        private ArrayList _directories = new ArrayList();
        private ArrayList _files = new ArrayList();

        public override IEnumerable Children
        {
            get { return _children; }
        }

        public override IEnumerable Directories
        {
            get { return _directories; }
        }

        public override IEnumerable Files
        {
            get { return _files; }
        }

        public ThemeDirectory(VirtualDirectory toFilter) : base(toFilter.VirtualPath)
        {
            _toFilter = toFilter;
            BuildChild();
        }

        private void BuildChild()
        {
            foreach (VirtualDirectory dirToFilter in _toFilter.Directories)
            {
                ThemeDirectory themeDir = new ThemeDirectory(dirToFilter);

                _children.Add(themeDir);
                _directories.Add(themeDir);
            }
            foreach (VirtualFile fileToFilter in _toFilter.Files)
            {
                if (string.Compare(VirtualPathUtility.GetExtension(fileToFilter.VirtualPath).TrimStart('.'), "css", true) != 0)
                {
                    _children.Add(fileToFilter);
                    _files.Add(fileToFilter);
                }
                else { }
            }

        }

    }
}
 
 

 


-Adam Kahtava [http://adam.kahtava.com]
4 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Mastering Web Development with Microsoft Visual Studio 2005 Authors: John Paul Mueller, Pages: 822, Published: 2005
Building Online Communities with Drupal, PhpBB, and WordPress Authors: Robert T. Douglass, Mike Little, Jared W. Smith, Pages: 530, Published: 2006
Programming Firefox: Building Applications in the Browser Authors: Kenneth C. Feldt, Pages: 494, Published: 2007
Essential ASP.Net 2.0 Authors: Fritz Onion, Keith Brown, Pages: 345, Published: 2006
Professional ASP.NET 2.0 Authors: Bill Evjen, Scott Hanselman, Farhan Muhammad, Srinivasa Sivakumar, Devin Rader, Pages: 1253, Published: 2005
Aperture Exposed: The Mac Photographer's Guide to Taming the Workflow Authors: Ellen Anon, Josh Anon, Pages: 297, Published: 2006
ASP.NET 2.0 Website Programming: Problem-design-solution Authors: Marco Bellinaso, Pages: 576, Published: 2006
FrontPage 2003 All-in-One Desk Reference For Dummies: all-in-one desk reference Authors: John Paul Mueller, Pages: 792, Published: 2004
Hacking Firefox: More Than 150 Hacks, Mods, and Customizations Authors: Mel Reyes, Pages: 430, Published: 2005

Web:
Theme basics - MoodleDocs Figure 2: The theme "standardwhite" with all CSS files from the theme ... Figure 6: The CSS file loading order of all Moodle CSS and theme CSS files. ...
Themes includes all CSS files - ASP.NET Forums Themes includes all CSS files. Last post 04-02-2007 12:31 PM by Adam.Kahtava. 3 replies. Sort Posts:. Oldest to newest, Newest to oldest ...
Theme Development « WordPress Codex style.css; index.php. Both of these files go into the Theme's directory. The index.php template file is very flexible. It can be used to include all ...
Put all css in one file - performance benefit? Now Drupal will combine all of the site CSS files (from drupal, the theme, and all modules) into a single compressed file. ...
Flex 3 - About themes With the exception of the default Halo theme, all of these themes are ... To build a theme SWC file, you create a CSS file, and include that file plus the ...
CSS File Structuring « Andy Peatling on WordPress Color/Theme This includes all of the CSS properties that relate to color and imagery within ... The theme CSS file would usually be given the theme name. ...
I don't want all these CSS files | drupal.org unset($css['all']['module']['sites/all/modules/cck/theme/content.css']) ... core stylesheets) you can include them in your themes .info file ...
PKP Support • View topic - referencing custom common files in a theme I've also placed all css background images in the themeOne ... versions* of those files in plugins/themes/MyTheme, and include some code in ...
dhtml menu javascript menu Currently there are 5 color themes (skin files) distributed with DynarchMenu:. skin-xp.css — color theme that resembles Windows XP menus. Includes ...
ASP.NET Themes and Skins Overview You can define skins in a separate file for each control or define all the skins for a ... A theme can also include a cascading style sheet (.css file). ...

Videos:
Wordpress Theme on Steroids Wordpress is an easy to use blogging tool. Unfortunately, the base configuration and themes bundled with the software are less than desirable. Now, S...
Long Beach City Council Meeting Long Beach City Council Meeting






sub menu not visible in ie

how can display a radio button before item in treeview control?

free skins?

problem with master pages in subfolders

master page and imagebutton issue....

sitemap usercontrol

help with master page. help.

show sub-menu in different place

treeview help, can't map to a server

server side subs in master page

sitemap for child project

master page does not exist parser error

regarding menu control

treeview - synchronizing changes to datasource

content place holder not matching master

localize navigationurl of asp:hyperlink

is there a way to turn off an "unknown server tag" for themes?

themes and printing

in a treeview, hovernodestyle does not take precedence/overrides style sheet hyperlink ('a') styles

treeview expanding behaviour

problems with stylesheets in master pages...

menu control not seen properly

has anyone used themes and skins with master pages?

object groups in skins

header-main(contentplaceholder)-footer layout

problem with masterpage

sitemappath

asp.net page reload

hide menu nodes

treeview control and xmldatasource

   
  Privacy | Contact Us
All Times Are GMT