By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,389 Members | 2,065 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,389 IT Pros & Developers. It's quick & easy.

Using themed css files requires a header control on the page

P: n/a
Hi,
I get this exception when I use a themed css file. In my web.config
file I have:
<pages theme="dRise">

and the trouble page is a master page :

<% Response.Write(Header)%>
<form id="form1" runat="server">
<div class="FormContent">
<asp:contentplaceholder id="ReportWizard" runat="server">
</asp:contentplaceholder>
</div>
</form>
<% Response.Write(Footer)%>

Header is a property returning :
"<html><head runat=""server""></head><body>"
and Footer returns:
"</body></html>"

The above code WORKS if I link the css file directely in the
masterpage, but if I use the themed css it generates the exception .
Can you help ?
thanks

Feb 21 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
DWS
Sam,
First off your thinking is right on the money. But your masterpage should
look something like this. More later.

<head runat="server">
<title>Sam's Master Page</title>
</head>
<body class="body">
<form id="form1" runat="server">
<div>

The exception was caused by the response.write This writes directly to the
client browser so <head runat="server"> was sent directly to the client web
browser. ASP.Net could not find the head element (it was sent to client web
browser) and threw an exception "no head element to put your css theme link
in"

Also Sam please start using a code behind or <script runat="server"> script
blocks for your coding. <% %> style coding is obsolete.

Good Luck
DWS
"sa*************@googlemail.com" wrote:
Hi,
I get this exception when I use a themed css file. In my web.config
file I have:
<pages theme="dRise">

and the trouble page is a master page :

<% Response.Write(Header)%>
<form id="form1" runat="server">
<div class="FormContent">
<asp:contentplaceholder id="ReportWizard" runat="server">
</asp:contentplaceholder>
</div>
</form>
<% Response.Write(Footer)%>

Header is a property returning :
"<html><head runat=""server""></head><body>"
and Footer returns:
"</body></html>"

The above code WORKS if I link the css file directely in the
masterpage, but if I use the themed css it generates the exception .
Can you help ?
thanks

Feb 22 '06 #2

P: n/a
Thanks for replying.
I actually do use code-behind, except in this one off circumpstance
where I've used <% %>. But this is not the problem, isn't it ?

I understood your explanations, but does this mean I can't write the
page dynamically when using a theme ?

Feb 22 '06 #3

P: n/a
In article <11**********************@g44g2000cwa.googlegroups .com>,
sa*************@googlemail.com writes
Thanks for replying.
I actually do use code-behind, except in this one off circumpstance
where I've used <% %>. But this is not the problem, isn't it ?
Yes, it's exactly the problem.
I understood your explanations, but does this mean I can't write the
page dynamically when using a theme ?


No, it means that what you write dynamically gets sent to the browser
without the ASP.NET engine doing anything with it. Your problem is that
you need a <head> tag with a runat="server" attribute in a place where
the ASP.NET engine will see it.

Why are you using the Response.Write to write out a bit of static HTML?
This should go in the master file, that's what they are there for. DWS'
point was that the <% %> style of coding is a classic ASP one that has
basically no place in ASP.NET. If you add the <head runat="Server"> to
your master file, then your theme will work fine.

Hope this helps.

--
Alan Silver
(anything added below this line is nothing to do with me)
Feb 27 '06 #4

P: n/a
of course it would worked if I added <head runat="server"> directely
in the page ! But I can't do it this way.
all the html markups from my project are coming from a database (from
<html> to <body>, including <head runat=server>)
therefore I have to use response.write to write this html dynamically
before the rest of the page.

Is this clear ?
Do you understand my probleme now ?

Feb 27 '06 #5

P: n/a
In article <11**********************@v46g2000cwv.googlegroups .com>,
sa*************@googlemail.com writes
of course it would worked if I added <head runat="server"> directely
in the page ! But I can't do it this way.
all the html markups from my project are coming from a database (from
<html> to <body>, including <head runat=server>)
therefore I have to use response.write to write this html dynamically
before the rest of the page.
You don't *have* to use Response.Write, see below.
Is this clear ?
It's clear, but it's going to cause you a big problem. To apply themes,
the ASP.NET engine needs to be able to parse the <head> tag of your
document at run time. If you are pulling this tag out of a database,
then it's not going to be available at run time, so you can't apply
theme.
Do you understand my probleme now ?


I do, do you understand now why it isn't working?

It sounds like you might need to rethink the way your data is stored.
Wouldn't you be better storing key information in the database and using
that as data for the tags, rather than storing the tags themselves?

For example, if you wanted to store a title for the page, instead of
saving the following in your database...

<head>
<title>my page</title>
</head>

you would be better storing just the text of the title ("my page" in
this case) and have server-side code like this...

<head>
<title><asp:Literal ID="litTitle" runat="server" /></title>
</head>

Then your page could extract the title from the database, and just set
the Text property of the literal to it. That sounds like a more sensible
system anyway, and would allow you to add the runat="server" attribute
to your <head> tag, allowing you to use themes.

Hope this helps

--
Alan Silver
(anything added below this line is nothing to do with me)
Feb 27 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.