CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 1/10/2007 5:03:19 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 5 Views: 26 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
6 Items, 1 Pages 1 |< << Go >> >|
johnglad
Asp.Net User
hide stylesheet1/10/2007 5:03:19 PM

0/0

I'm using themes in my .net application. I have some extra css files, which are used for fixing IE rendering issues.

screen.css
ie6.css

When the page is rendered, both stylesheets are included in the <head>. I don't want ie6.css to be automatically include. Is there a way to tell .net exactly what stylesheet to use for the theme, so that all others in the folder are ignored?

thanks
 

RichardMathis
Asp.Net User
Re: hide stylesheet1/10/2007 10:08:31 PM

0/0

I'm not certain where in the life cycle theme elements are added individually, I have a feeling you could possibly use reflection to get access to it, but ultimately its probably more difficult than is necessary.

What I would do, is either A)  Create 2 themes, one for IE and one not  or B) remove the ie.css file from the theme and add it after the fact if the browser is IE.

I always create a class to inherit all of my pages from so I can easily do these sorts of things.  So in my baseclass.vb file, I put

Me.Header.Controls.AddAt(0, New LiteralControl("<link rel=""stylesheet"" type=""text/css"" href=""/utility/ie.css"" />"))

into the page load event.  I tried to put it in my init event where my user custom theme is loaded but the header isn't available at that point in the lifecycle.

Let me know if that works for you.

 


Richard Mathis
Dndorks Webmaster
http://dndorks.com/
TopWebcomics Webmaster
http://topwebcomics.com/
Adam.Kahtava
Asp.Net User
Re: hide stylesheet1/11/2007 1:39:37 PM

0/0

CSS is a powerful styling language. ASP.NET has always depended on CSS and Styles in some form - both ASP.NET Skins and the ASP.NET inline styling attributes depend on CSS and the associated styles.

However; Themes take an overly simplistic approach to CSS (as you've discovered).

There are a couple alternatives, but the easiest is to move your CSS out of the Themes directory and manually include them in the Master Page <head> tag.

I outlined some of the downfalls of Themes and CSS in the following blog post: The Problems with Themes, Skins, and Cascading Style Sheets (CSS) - Where it all Falls Apart

I'd be interested in hearing about any other problems you've encountered with CSS and Themes. 


-Adam Kahtava [http://adam.kahtava.com]
johnglad
Asp.Net User
Re: hide stylesheet1/12/2007 7:36:33 AM

0/0

Nice, thanks for the suggestion. The following worked. I haven't tested it extensively yet, but it seems promising.

public class BasePage : System.Web.UI.Page
    {
    protected override void OnLoad(EventArgs e)
    {
        //add ie6 and ie7 only stylesheets
        string path = Request.ApplicationPath + "/assets/";

        this.Header.Controls.Add(new LiteralControl("<!--[if IE 6]><link rel=\"stylesheet\" type=\"text/css\" href=\""+path+"ie6.css\" media=\"screen\"/><![endif]-->"));
        this.Header.Controls.Add(new LiteralControl("<!--[if IE 7]><link rel=\"stylesheet\" type=\"text/css\" href=\""+path+"ie7.css\" media=\"screen\"/><![endif]-->"));
    }
}
 


 

johnglad
Asp.Net User
Re: hide stylesheet1/12/2007 8:09:57 AM

0/0

Nice articles Adam.Kahtava

I'll be honest, I'm regretting using themes. They just don't mesh well with good css.

Adam.Kahtava
Asp.Net User
Re: hide stylesheet1/12/2007 1:49:49 PM

0/0

johnglad:

Nice, thanks for the suggestion. The following worked. I haven't tested it extensively yet, but it seems promising.

public class BasePage : System.Web.UI.Page
    {
    protected override void OnLoad(EventArgs e)
    {
        //add ie6 and ie7 only stylesheets
        string path = Request.ApplicationPath + "/assets/";

        this.Header.Controls.Add(new LiteralControl("<!--[if IE 6]><link rel=\"stylesheet\" type=\"text/css\" href=\""+path+"ie6.css\" media=\"screen\"/><![endif]-->"));
        this.Header.Controls.Add(new LiteralControl("<!--[if IE 7]><link rel=\"stylesheet\" type=\"text/css\" href=\""+path+"ie7.css\" media=\"screen\"/><![endif]-->"));
    }

Your proposed solution will work, but it really makes things more complex then they have to be.

Furthermore; Web Designers or CSS experts don't generally know C#, so this solution has the potential to limit future maintenance. As a rule of thumb it's good to keep things simple; implementing work arounds for the way Themes treat CSS files (disregarding media types, disregarding load order preference, disregarding conditional comments, and so on) really makes things more complex then they actually are - It turns into a case of not seeing the forest from the trees.

Themes can work for you, and default skins are nice for specifying the CssClass, but giving complete CSS control to Themes introduces problems.

Anyhow; glad you found the articles useful, I'd be interested in any alternative work arounds or suggestions you have. 


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


Free Download:

Books:
Beginning CSS: Cascading Style Sheets for Web Design Authors: Richard York, Pages: 630, Published: 2007
Real World QuarkXPress 5: For Macintosh and Windows Authors: David Blatner, Pages: 1032, Published: 2002
Dreamweaver CS3 For Dummies Authors: Janine Warner, Pages: 434, Published: 2007
HTML & XHTML: The Definitive Guide Authors: Chuck Musciano, Bill Kennedy, Pages: 654, Published: 2007
Dreamweaver CS3 Bible: Master Every Aspect of Dreamweaver - Work with CSS, Text, Images, And Links - Incorporate Flash Movies and Other Media Authors: Joseph W. Lowery, Pages: 1112, Published: 2007
Dreamweaver MX 2004: The Missing Manual Authors: David Sawyer McFarland, David Pogue, Pages: 836, Published: 2004
CSS: The Missing Manual Authors: David Sawyer McFarland, David McFarland, Pages: 476, Published: 2006
Dreamweaver CS3: The Missing Manual Authors: David Sawyer McFarland, Pages: 995, Published: 2007
Cascading Style Sheets: Designing for the Web Authors: Håkon Wium Lie, Bert Bos, Pages: 392, Published: 2005

Web:
hide css style sheet is there a way i can hide the style sheet i use from the user? like they cant access it or view it?
hide stylesheet - ASP.NET Forums hide stylesheet. Last post 01-12-2007 8:49 AM by Adam.Kahtava. 5 replies. Sort Posts:. Oldest to newest, Newest to oldest ...
Dynamic StyleSheets styleSheets) document.styleSheets[0].href = mySheet + '.css'; else if (document. layers) { document.layers['style1'].visibility = 'hide'; ...
Bobby van der Sluis » Articles » Using dynamic CSS to hide content ... Sep 28, 2005 ... And a stylesheet named hide.css that includes: #el {display:none;}. Although this solution works fine as it is, it still can be improved ...
Eric Meyer on CSS: Tricking Browsers and Hiding Styles Neither line leads to any useful results, so the effect is to hide the external style sheet adv-styles.css from these browsers. ...
Browser Specific Stylesheets : Realitystorm.com uses the @import to hide the style sheet from Netscape 4.x browsers ... used Tantek Çelik comment hack to hide IE Mac stylesheets from all other browsers. ...
Qt-interest Archive - flicker when hide() QPushButton with ... Subject: flicker when hide() QPushButton with stylesheet (background-image); From: Felix Hammer ; Date: Fri, ...
Cascading Style Sheet Compatibility in Internet Explorer 7 Jan 31, 2006 ... It used to hide properties exclusive to Internet Explorer under the strict .... comments to set up a link to an IE-specific style sheet. ...
Index ... not rendered 1: used to hide script data 1: used to hide style sheet data 1; conformance 1; content model 1: excluded elements in 1: syntax of in DTD 1 ...
Print Stylesheets @ Flog, by Adam Burmister The first step of course is to hide the printable logo, so in your screen, projection stylesheet you should add: #logo img { visibility: hidden; /* hide the ...




Search This Site:










global theme location

regex question

reboot on dnn compilation

bug: object reference not set to an instance of an object.

what is the vb equivalent of the stuff function?

smtp.net component

listbox woes - selecteditem not preserved in viewstate...

erwdsf sdfsdf

will dnn support mobile devices?

proposal - module definitions, containers, and behaviors?

shauns blog of wednesday, november 12, 2003 - the null problem.

http post problem

wse exception : wse910

accesibility concerns

have bugs you want to see fixed in the commerce starter kit?

converting from vb array to c#

multiple controls/pages in a single module

looking for suggestions on string manipuation for module content

skinfile or css

getting milestones module to inherit portal look and feel

use profile in base class

sending dataset from page to masterpage

windows authentication - signing in as a different user

web.config security in shared hosting environment

menu control problem

encrypted password problem in formsauthentication.authenticate method

source code of modules for dnn 3.3

problems with subdomains

format a string

https reference in i/frame page

 
All Times Are GMT