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, 01: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, 02: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
>
>



=?Utf-8?B?RFdT?=
  Reply With Quote
Old 02-22-2006, 04: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.



samuelberthelot@googlemail.com
  Reply With Quote
Old 03-01-2006, 10: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)


Alan Silver
  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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
master page does not change due to preinit event not firing franchise63 General Help Related Topics 0 02-13-2008 09:18 AM
master page & app_theme folder doesn't work dummies2 General Help Related Topics 0 09-04-2007 05:41 PM
Classic Original Broadcasts Trading List - Updated ( w/o/c ) porkys1982@sbcglobal.net DVD Video 0 12-05-2005 03:38 AM
Classic Original Broadcasts Trading List - Updated ( w/o/c ) porkys1982@sbcglobal.net DVD Video 0 11-19-2005 04:46 PM
High Definition and the future of viewing. Allan DVD Video 3 03-09-2005 12:56 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46