Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - dynamic master page content

 
Thread Tools Search this Thread
Old 02-21-2006, 12:54 PM   #1
Default dynamic master page content


Hi,
In one of my database's tables I have a Header and Footer field, which
content is used to create the header and footer of my Master page.


Part generated from Header field:
<html >
<head >
<title>Untitled Page</title>
</head>

<body>

That's the usual hardcoded content part of the Master Page:
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">

and finally the part generated from the Footer field:
</body>
</html>

How can I build the header and footer of my Master page by reading the
content of my datasource ??

Thank you



samuelberthelot@googlemail.com
  Reply With Quote
Old 02-22-2006, 01:58 PM   #2
=?Utf-8?B?RFdT?=
 
Posts: n/a
Default RE: dynamic master page content

Sam,
You'll need to modify your application to not use the header and footer from
your database. Let asp.net render the <head> <html> <body> tags. You can
change the page title with page.title="hello world" . You can add your meta
tags to the head element in the masterpage with a usercontrol.

Good Luck
DWS


"" wrote:

> Hi,
> In one of my database's tables I have a Header and Footer field, which
> content is used to create the header and footer of my Master page.
>
>
> Part generated from Header field:
> <html >
> <head >
> <title>Untitled Page</title>
> </head>
>
> <body>
>
> That's the usual hardcoded content part of the Master Page:
> <asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
>
> and finally the part generated from the Footer field:
> </body>
> </html>
>
> How can I build the header and footer of my Master page by reading the
> content of my datasource ??
>
> Thank you
>
>

  Reply With Quote
Old 02-22-2006, 03:26 PM   #3
samuelberthelot@googlemail.com
 
Posts: n/a
Default Re: dynamic master page content

Well it's the way the whole system work, i'm afraid i can't change that
and i'm not the one who has designed this.
Actually I've managed to achieve this:

In the code-behind of my master page, if it's not a PostBack, I read
the header an footer from database and store them in two session
variable. I write them using response.write and the page is built
correctely. Only issue I have is with .css, mentionned in another post
of mine.

  Reply With Quote
Old 03-01-2006, 09:18 AM   #4
Alan Silver
 
Posts: n/a
Default Re: dynamic master page content

In article < om>,
writes
>Well it's the way the whole system work, i'm afraid i can't change that
>and i'm not the one who has designed this.


Well, it might be worth speaking to whoever did design it and explaining
that it's not a very good solution.

>Actually I've managed to achieve this:
>
>In the code-behind of my master page, if it's not a PostBack, I read
>the header an footer from database and store them in two session
>variable. I write them using response.write and the page is built
>correctely.


What happens when the session runs out? Say someone loads a page, then
goes for a cup of tea, comes back after the session has expired and
submits the page? Your session variable will be empty, but you only
populate it on postback, so your header and footer will not appear.

BY the way, using response.write is not a recommended way to build pages
anymore. It was fine in classic ASP, but there are much better ways in
ASP.NET.

> Only issue I have is with .css, mentionned in another post
>of mine.


I suspect you will find bigger issues than that as time goes on unless
you rethink your approach. You are going about things in a very "classic
ASP" way, not a recipe for success.

I would rethink this very carefully before proceeding. You should only
store the header and footer *content* (eg, page title, meta keywords,
etc) in the database, and *not* the tags. HTML should be left for the
pages themselves.

HTH

--
Alan Silver
(anything added below this line is nothing to do with me)
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump