Exclude stylesheet from page directive

J

Jonas

Hi

I have created a web site that uses themes. After publishing the web site I
tried to change the theme in the web.config file, but nothing was changed.
After checking the published aspx files I noticed that the compiler had
added my compile time theme to the page directive of each file:

theme="Theme1" stylesheettheme="Theme1" %>

Is there any way that I can stop this behaviour? I would like to be able to
change the current theme in the web.config of each installation, without
needing to update each aspx file and without having to change my local
config file before compiling.

/Jonas
 
J

James Irvine

Jonas said:
Hi

I have created a web site that uses themes. After publishing the web
site I tried to change the theme in the web.config file, but nothing was
changed.
After checking the published aspx files I noticed that the compiler had
added my compile time theme to the page directive of each file:

theme="Theme1" stylesheettheme="Theme1" %>

Is there any way that I can stop this behaviour? I would like to be able
to change the current theme in the web.config of each installation,
without needing to update each aspx file and without having to change my
local config file before compiling.

/Jonas


in web.config, this will override individual page settings:

<configuration>
<system.web>
<pages theme="ThemeName" />
</system.web>
</configuration>



this will give priority to the individual pages:

<configuration>
<system.web>
<pages styleSheetTheme="Themename" />
</system.web>
</configuration>




http://msdn.microsoft.com/en-us/library/0yy5hxdk.aspx
 
J

Jonas

Thanks. I don´t know much about web development. I "inherited" a project
with the following line in the configuration file:

<configuration>
<system.web>
<pages masterPageFile="~/MasterPage.master" theme="Theme1"
styleSheetTheme="Theme1">
</system.web>
</configuration>

If I remove 'styleSheetTheme="Theme1"', will that solve the problem?? I
tried to deploy like that, but the code theme="Theme1" was still copied to
all aspx files.

I tried to totally remove 'theme="Theme1" styleSheetTheme="Theme1"' from the
config file and after publishing I noticed that the theme references in the
individual aspx files were gone. After that I added the themes to the config
file at the production site and it all worked. So the problem seems to be
that the theme references are copied to the aspx files when deploying. Is
there no way to avoid this?

/Jonas
 
J

James Irvine

Jonas said:
Thanks. I don´t know much about web development. I "inherited" a project
with the following line in the configuration file:

<configuration>
<system.web>
<pages masterPageFile="~/MasterPage.master" theme="Theme1"
styleSheetTheme="Theme1">
</system.web>
</configuration>

If I remove 'styleSheetTheme="Theme1"', will that solve the problem?? I
tried to deploy like that, but the code theme="Theme1" was still copied
to all aspx files.

I tried to totally remove 'theme="Theme1" styleSheetTheme="Theme1"' from
the config file and after publishing I noticed that the theme references
in the individual aspx files were gone. After that I added the themes to
the config file at the production site and it all worked. So the problem
seems to be that the theme references are copied to the aspx files when
deploying. Is there no way to avoid this?

/Jonas

I presume you're looking at the page source after the page is rendered?
I tested your setup on my machine and verified, yes, at rendering
time asp auto-generates code to include files associated with your
web.config specification.

For example, I had this in my web.config file:
<pages theme="PhotosTheme">


In my App_Themes\PhotosTheme directory I has these files:
monteStuff.css, photos.css and photos.skin


I had no reference in any web page to any theming, only in web.config.
But when the page gets rendered, the code behind shows asp dynamically
added this line:


<link href="App_Themes/PhotosTheme/monteStuff.css" type="text/css"
rel="stylesheet" /><link href="App_Themes/PhotosTheme/photos.css"
type="text/css" rel="stylesheet" />


So to answer your question, no, you can't avoid this by flipping a
switch. You avoid this indirectly by setting whatever combination of
web.config and individual page directives that work for you. That
determines what gets auto-generated.

I think web.config expects one or the other, but not both
styleSheetTheme=xxx and theme=xxx. So if you would like to, as you say,
apply a theme to the whole site without having to go change individual
pages, use <pages theme="PhotosTheme" in web.config.
 

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,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top