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 / Visual Studio.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

calling style sheets

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jrl - 07 Mar 2008 04:00 GMT
At first I learned to call a style sheet by the command
EnableTheming, as in
<%@ Master EnableTheming="true" Language="C#" AutoEventWireup="true"
CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
Using this form to call the style sheet in the App_Themes folder worked
fine.

But then I needed to break my stylesheet into smaller chunks, so it was
recommended that I use the following form within the head section.
    <link rel="Stylesheet" type="text/css" media="screen"
href="~/App_Themes/screen.css"

Now I notice the references to styles, are generating an interpreter warning
"The class or CssClass value is not defined" when I view the source code,
even though it does load the linked stylesheet and implements the styles
when it generates the webpage.

Is this normal? (that it would warn this error) or am I missing something in
order to use this function?
jrl - 07 Mar 2008 04:21 GMT
Sorry, I didn't make it clearer that the error "The class or CssClass value
is not defined" comes up like a tool tip when I hover over the CssClass,
like over pageheader in the following code:
<div class = "pageheader" >
where pageheader is defined in the css stylesheet as

.pageheader
   {
       background-color: #F3F194;
       color: #5A5AA5;
   }

Also, I notice that when I used the enabletheming, I could set the property
of a control, in the properties panel, and select the cssclass from a
dropdown. Now that I use the linked stylesheet, I don't get any style
options in the properties panel for any control.

So how can I use the linked reference to the stylesheet (<link
rel="Stylesheet" ...>), and still get the utility I had with enabletheming
(<%@ Master EnableTheming="true" ....>)?

> At first I learned to call a style sheet by the command
> EnableTheming, as in
[quoted text clipped - 15 lines]
> Is this normal? (that it would warn this error) or am I missing something
> in order to use this function?
Steven Cheng - 07 Mar 2008 07:44 GMT
Hi jrl,

From your description, you're using ASP.NET Theme feature and include some
css style sheets in Theme (which will be applied on page), however, you
found the css class can not be resolved on page, correct?

According to the App_Themes folder and stylesheet path (also the <link ...>
tag syntax), I found the following problems:

** For ASP.NET theme, you need to assigne a certain Theme value for page in
addition to enabling Theme, e.g.

<%@ Page Language="C#" ............ EnableTheming="true" Theme="Theme1" %>

** You can add multiple Themes into App_Themes folder and each theme has
all its content(skins or stylesheets) in the subfolder of their name. e.g.

/App_Themes/
          /Theme1
                   stuffs for Theme1
          /Theme2
                   stuffs for Theme2

** For css stylesheets, if you want a certain Theme include some css
styles, just put the css stylesheet file into the folder of that Theme. And
at runtime the page will automatically reference those css stylesheets(as
long as you've applied the theme on that page):

here are some further articles about using Theme in ASP.NET:

#ASP.NET Themes and Skins Overview
http://msdn2.microsoft.com/en-us/library/ykzx33wh.aspx

#Themes In ASP.NET 2.0
http://www.odetocode.com/Articles/423.aspx

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we

can improve the support we provide to you. Please feel free to let my
manager know what you think of

the level of service provided. You can send feedback directly to my manager
at: msdnmg@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to

http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response

from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take

approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution.

The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump

analysis issues. Issues of this nature are best handled working with a
dedicated Microsoft Support

Engineer by contacting Microsoft Customer Support Services (CSS) at

http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>X-Trace-PostClient-IP: 70.67.40.71
>From: "jrl" <jrl@newsgroup.nospam>
>Newsgroups: microsoft.public.vsnet.general
>Subject: Re: calling style sheets

>Sorry, I didn't make it clearer that the error "The class or CssClass value
>is not defined" comes up like a tool tip when I hover over the CssClass,
[quoted text clipped - 36 lines]
>> Is this normal? (that it would warn this error) or am I missing something
>> in order to use this function?
jrl - 09 Mar 2008 09:55 GMT
I tried using the named theme as you suggest, but got an error because it is
for a master page.
<%@ Master Language="C#" AutoEventWireup="true"
CodeFile="MasterPage.master.cs" Inherits="MasterPage" EnableTheming="true"
Theme="~/App_Themes/rosy/screen.css" %>

Error: "Attribute Theme is not valid on a master page. However, the visual
designer accepts this attribute while you are editing the master page."

But this might be an unrelated issue, since what I'm trying to do is use the
alternate method of loading stylesheet

for example:     <link rel="Stylesheet" type="text/css" media="screen"
href="~/App_Themes/rosy/screen.css" />

And I want to load three stylesheets (one for each type of media: screen,
print, and handheld).

How can I load multiple stylesheets with this alternate method?

> Hi jrl,
>
[quoted text clipped - 132 lines]
> something
>>> in order to use this function?
Steven Cheng - 10 Mar 2008 02:46 GMT
Hi Jrl,

Thanks for your reply.

It seems there is some misunderstanding here.

In the page's "Theme" attribute, you should assign the name of the
Theme(rather than path). Therefore, for your case, you've put a theme named
"rosy" under App_Themes folder  (/App_Themes/rosy), you should use the
following syntax to reference this theme in page:

<%@ Master Language="C#" AutoEventWireup="true"
CodeFile="MasterPage.master.cs" Inherits="MasterPage" EnableTheming="true"
Theme="rosy" %>

Also, for stylesheets, as I mentioned in previous thread, you do not need
to explicitly reference the stylesheet in page, you just need to put those
stylesheets(you want to use in page) under the Theme folder (the
/App_Themes/rosy/.. in your case here). When you applied the "rosy" theme
to page, it will automatically link those stylesheets in page's html
output(you can verify it in your client browser's viewsource).

Also, I suggest you read some articles or reference about using Theme in
ASP.NET, that'll help you understand how it works better.

Best regards,

Steven Cheng
Microsoft MSDN Online Support Lead

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we

can improve the support we provide to you. Please feel free to let my
manager know what you think of

the level of service provided. You can send feedback directly to my manager
at: msdnmg@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>Newsgroups: microsoft.public.vsnet.general
>References: <d53Aj.53475$pM4.21522@pd7urf1no>
<op3Aj.53393$w94.4716@pd7urf2no> <dvT#icCgIHA.6844@TK2MSFTNGHUB02.phx.gbl>
>In-Reply-To: <dvT#icCgIHA.6844@TK2MSFTNGHUB02.phx.gbl>
>Subject: Re: calling style sheets

>I tried using the named theme as you suggest, but got an error because it is
>for a master page.
[quoted text clipped - 73 lines]
>> ==================================================
>> Get notification to my posts through email? Please refer to

http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
>> ications.
>>
[quoted text clipped - 73 lines]
>> something
>>>> in order to use this function?
jrl - 10 Mar 2008 03:53 GMT
Ok, I have read the articles you recommended, thanks. I am still getting the
error
"Theme is not valid on a master page. However, the visual
designer accepts this attribute while you are editing the master page."

The syntax I am using is
<%@ Master Language="C#" AutoEventWireup="true"
CodeFile="MasterPage.master.cs" Inherits="MasterPage"  EnableTheming="true"
Theme="rosy" %>

"rosy" refers to a folder under App_Themes, containing 3 css files.

Am I doing something wrong still?

> Hi Jrl,
>
[quoted text clipped - 216 lines]
>>> something
>>>>> in order to use this function?
jrl - 10 Mar 2008 03:54 GMT
Further, the error when I compile is
Error 4 Error parsing attribute 'theme': Type 'System.Web.UI.MasterPage'
does not have a public property named 'theme'.

> Ok, I have read the articles you recommended, thanks. I am still getting
> the error
[quoted text clipped - 238 lines]
>>>> something
>>>>>> in order to use this function?
Steven Cheng - 10 Mar 2008 06:09 GMT
Thanks for your quick reply Jrl,

This is my fault here. I should have pointed out the problem that Master
page does not support "Theme" property, therefore, you can not add "Theme"
attribute in   <%@ Master  %> directive.

For declarative Theme setting ,you need to set the "Theme" attribute in
content page.  Or you can consider programmatically set Theme for a page(in
master page). e.g.

================
public partial class site : System.Web.UI.MasterPage
{
   protected void Page_PreInit(object sender, EventArgs e)
   {
       Page.Theme = "my theme";
   }
...............
==============

#Note: you can only programmatically set Theme in PreInit event since
that's the earliest event you can get to do this.

Best regards,

Steven Cheng
Microsoft MSDN Online Support Lead

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we

can improve the support we provide to you. Please feel free to let my
manager know what you think of

the level of service provided. You can send feedback directly to my manager
at: msdnmg@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>X-Trace-PostClient-IP: 70.67.40.71
>From: "jrl" <jrl@newsgroup.nospam>
>Newsgroups: microsoft.public.vsnet.general
>In-Reply-To: <zo1Bj.65287$w94.58704@pd7urf2no>
>Subject: Re: calling style sheets

>Further, the error when I compile is
>Error 4 Error parsing attribute 'theme': Type 'System.Web.UI.MasterPage'
[quoted text clipped - 156 lines]
>>>>> ==================================================
>>>>> Get notification to my posts through email? Please refer to

http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
>>>>> ications.
>>>>>
[quoted text clipped - 80 lines]
>>>>> something
>>>>>>> in order to use this function?
jrl - 10 Mar 2008 06:29 GMT
Great! I'm sure we're getting closer now.

I have the code behind of the masterpage (masterpage.master.cs) with the
following:

public partial class site : System.Web.UI.MasterPage
{
   protected void Page_PreInit(object sender, EventArgs e)
   {
       Page.Theme = "rosy";
   }
}

public partial class MasterPage : System.Web.UI.MasterPage
{
  protected void Page_Load(object sender, EventArgs e)
   {
       // content removed here, just wanted to show the structure of
keeping the page_load and Page_PreInit separate.
   }

}

In the masterpage.master I use the form
<%@ Master Language="C#" AutoEventWireup="true"
CodeFile="MasterPage.master.cs" Inherits="MasterPage"   EnableTheming="true"
%>

I also tried removing EnableTheming="true".

However, although it compiles fine, this setup results in a page which has
no style sheet applied.

> Thanks for your quick reply Jrl,
>
[quoted text clipped - 305 lines]
>>>>>> something
>>>>>>>> in order to use this function?
Steven Cheng - 10 Mar 2008 07:23 GMT
Hi Jrl,

The behavior you got is correct. Though you can only specify which Theme to
use at content page level(and only one theme for each page), you can set
"EnableTheming" at multiple level(give you different granularity of control
on Theme).  You can set EnableTheming  on content page, or on Master Page
or even on ascx usercontrol.

Actually, you can consider Master page as a particular usercontrol.  
Therefore, you need to set "EnableTheming = true" on master page so as to
make the Theme/style on it work.

Best regards,

Steven Cheng
Microsoft MSDN Online Support Lead

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we

can improve the support we provide to you. Please feel free to let my
manager know what you think of

the level of service provided. You can send feedback directly to my manager
at: msdnmg@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>X-Trace-PostClient-IP: 70.67.40.71
>From: "jrl" <jrl@newsgroup.nospam>
>In-Reply-To: <jRLemzmgIHA.4672@TK2MSFTNGHUB02.phx.gbl>
>Subject: Re: calling style sheets

>Great! I'm sure we're getting closer now.
>
[quoted text clipped - 248 lines]
>>>>>>> ==================================================
>>>>>>> Get notification to my posts through email? Please refer to

http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
>>>>>>> ications.
>>>>>>>
[quoted text clipped - 84 lines]
>>>>>>> something
>>>>>>>>> in order to use this function?
jrl - 10 Mar 2008 07:40 GMT
Ok... As they say 'back to the drawing board' !

My original goal was to create media sets in one big css file, but for some
reason the length of the css file created problems with a css validation
tool. Therefore, I tried to break the css file into separate media files.
Thats when it was suggested that I could stop using the enabletheming
approach, and begin using an alternate approach, where I call the css file
explicitly, as in  <link rel="Stylesheet" type="text/css" media="screen"
href="~/App_Themes/rosy/screen.css" />

Do you think that approach could work, to allow me to call three css files,
in the master page? and deal with the error "The class or CssClass value is
not defined" that results when I use this linking format?

If not, can you suggest any method that would allow allow me to call 3 css
files into the master page?

> Hi Jrl,
>
[quoted text clipped - 399 lines]
>>>>>>>> something
>>>>>>>>>> in order to use this function?
Steven Cheng - 11 Mar 2008 03:16 GMT
Thanks for your reply Jrl,

So you do not want to page to "EnableTheming=true" and automatically link
all those css stylesheets in Theme folder?

If you want to explicitly reference the css styesheet and use a "~/ ..."
based url(which is ASP.NET application specific path), you can consider the
following approah:

#1 make sure <head> is not runat ="server" and use inline code to inject
the path of the css style:
============
<head>
...

<link rel="Stylesheet" href='<%=
Page.ResolveUrl("~/App_Themes/Theme1/othersheet.css") %>' />

============

#2 or you can let <head> ast "runat=server" and use codebehind to add the
css style reference.

=====================
<head runat="server" >

protected void Page_Load(object sender, EventArgs e)
   {

       HtmlLink csslink = new HtmlLink();
       csslink.Attributes["type"] = "text/css";
       csslink.Attributes["rel"] = "stylesheet";
       csslink.Attributes["href"] =
Page.ResolveUrl("~/App_Themes/Theme1/othersheet.css");

       Page.Header.Controls.Add(csslink);
   }

=============================

Best regards,

Steven Cheng
Microsoft MSDN Online Support Lead

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we

can improve the support we provide to you. Please feel free to let my
manager know what you think of

the level of service provided. You can send feedback directly to my manager
at: msdnmg@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>X-Trace-PostClient-IP: 70.67.40.71
>From: "jrl" <jrl@newsgroup.nospam>
[quoted text clipped - 322 lines]
>>>>>>>>> ==================================================
>>>>>>>>> Get notification to my posts through email? Please refer to

http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
>>>>>>>>> ications.
>>>>>>>>>
[quoted text clipped - 92 lines]
>>>>>>>>> something
>>>>>>>>>>> in order to use this function?
jrl - 11 Mar 2008 05:08 GMT
Thanks for persevering with this issue. It's not that I don't want to use
"EnableTheming=true", its that it doesn't provide the functionality I am
seeking. I say this because of your note that one needs to specify the theme
on the content page. I'm trying to avoid that, just using the master page.
And, as mentioned, each of the css share similar classes, so I need to use
the media tag, which isn't called with the theming approach.

Anyway, I was able to use both of the forms you suggested. Although they
both work, in terms of being able to apply the css styling, there is no
effect in terms of the problems I first mentioned. The problem was that,
when I use multiple css files, (each related to a different media, but
sharing many of the same classes), then Visual Studio 2008 generates a
warning on every use of any of the styles. The warning again is, "the class
or CssClass value is not defined". It generates this warning, even though it
is using the style sheet as intended.

I explored this issue on the asp.net forum as well,
(http://forums.asp.net/t/1231590.aspx). There we discovered that this
warning only occurs in Visual Studio 2008. The same basic code does not
generate a warning in VS 2005.

Maybe I discovered a bug!

> Thanks for your reply Jrl,
>
[quoted text clipped - 511 lines]
>>>>>>>>>> something
>>>>>>>>>>>> in order to use this function?
Steven Cheng - 12 Mar 2008 03:04 GMT
Hi Jrl,

Thanks for the followup.

Yes, I agree that there are some more UI specific parts that I'm not quite
good at(I mainly focus on the code logic part).  I've read that thread,
seems there is some design-time css validation problem in VS 2008 as the
customer in the forum thread indicate. I suggest you submit this problem as
a issue report to our product feedback center:

https://connect.microsoft.com/feedback/default.aspx?SiteID=210

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we

can improve the support we provide to you. Please feel free to let my
manager know what you think of

the level of service provided. You can send feedback directly to my manager
at: msdnmg@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>X-Trace-PostClient-IP: 70.67.40.71
>From: "jrl" <jrl@newsgroup.nospam>
>In-Reply-To: <julL03xgIHA.4200@TK2MSFTNGHUB02.phx.gbl>
>Subject: Re: calling style sheets

>Thanks for persevering with this issue. It's not that I don't want to use
>"EnableTheming=true", its that it doesn't provide the functionality I am
[quoted text clipped - 427 lines]
>>>>>>>>>>> ==================================================
>>>>>>>>>>> Get notification to my posts through email? Please refer to

http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
>>>>>>>>>>> ications.
>>>>>>>>>>>
[quoted text clipped - 101 lines]
>>>>>>>>>>> something
>>>>>>>>>>>>> in order to use this function?

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.