Home All Groups Group Topic Archive Search About

dynamic master page content

Author
21 Feb 2006 1:54 PM
samuelberthelot
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

Author
22 Feb 2006 2:58 PM
DWS
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


Show quoteHide quote
"samuelberthe***@googlemail.com" 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
>
>
Are all your drivers up to date? click for free checkup

Author
22 Feb 2006 4:26 PM
samuelberthelot
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.
Author
1 Mar 2006 10:18 AM
Alan Silver
In article <1140625573.204893.7***@g43g2000cwa.googlegroups.com>,
samuelberthe***@googlemail.com 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)

Bookmark and Share