473,471 Members | 1,684 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Master-Content in Asp.net - How to set individual Head for each content page

Hello,
Master-Content in asp.net is very powerful.
But:
I have the following:
One Master-Form.
30 Content-Forms which are the webpages used.
Each of this content-forms must have own html-Head-informations.
Example
Master:
<head>
..... for alle content pages
</head>

ContentPage01
<head>
..... from master
individual for this page, for example:
javascript includes
meta-tags
css-style-sheets
</head>

ContentPage02
<head>
..... from master
individual for this page, for example:
javascript includes
meta-tags
css-style-sheets
</head>

etc.

So what to do.
It is not possible to have <head>.... </headin content-pages.
It is not possible to put all in the <head></headin the master
because is different for each page.

So, what to do?
Thank you for any help.
Rolf Welskes
Aug 21 '06 #1
7 2175
"Rolf Welskes" <ro**@nospam.nospamwrote in message
news:OA**************@TK2MSFTNGP06.phx.gbl...
So, what to do?
In the Page_Load of the content pages:

protected void Page_Load(object sender, EventArgs e)
{
Header.Title = "Whatever you like";
}
Aug 21 '06 #2
Check out the System.Web.UI.HtmlControls namespace [1] and study the
HtmlHead, HtmlMeta, HtmlLink classes and so on.

The challenge is how and what to code to the header for various content
pages. You'll have to start using a base class all content pages inherit
from. From the Page_PreInit handler of the base class your code will invoke
another class with methods that can determine which content page is about to
be used and subsequently which classes from the HtmlControls namespace are
to be used given the circumstantial requirements for that specific content
page.

Clear as mud?

<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://clintongallagher.metromilwaukee.com/
MAP 43°2'17"N 88°2'37"W : 43°2'17"N 88°2'37"W

[1] http://msdn2.microsoft.com/en-us/lib...lcontrols.aspx
"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:et**************@TK2MSFTNGP04.phx.gbl...
"Rolf Welskes" <ro**@nospam.nospamwrote in message
news:OA**************@TK2MSFTNGP06.phx.gbl...
>So, what to do?

In the Page_Load of the content pages:

protected void Page_Load(object sender, EventArgs e)
{
Header.Title = "Whatever you like";
}

Aug 21 '06 #3
the @Page directive in content page has a attribute "title", so you can
modify it to meet your requirememt,e.g.,
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" Title="XXX"
%>

Aug 22 '06 #4
Hello Rolf,

For your scenario, do you think it possible and doable that we use code to
programmatically create and add html items into the <headersections of
content page? If so, you can consider dynamically creating those html
header items (as Clinton has mentioned) and add them into your content
page's Header. .e.g.

===================================
protected void Page_Load(object sender, EventArgs e)
{
// modify existing <metadefined in master page
HtmlMeta meta = Page.Header.FindControl("metaRedirect") as HtmlMeta;

meta.Content = "";// "2;URL=http://msdn2.microsoft.com/";

// adding new elements into content page's header

HtmlLink link = new HtmlLink();
link.Href = "~/styles/default.css";
link.Attributes["rel"] = "stylesheet";

Page.Header.Controls.Add(link);
HtmlGenericControl script = new HtmlGenericControl("script");
script.Attributes["src"] = Page.ResolveUrl("~/scripts/default.js");

Page.Header.Controls.Add(script);

..................
}

==================================

Hope this helps.
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.


Aug 22 '06 #5

Hello,
thank you for the comments, I think it will help to solve the problem.

BUT:
All is done in program code.

Hint for Microsoft:

It would be very easy to have a head-tag
<head>.... </headalso in the content pages and when merging content and
master,
simple the head information of the content is append in the master.

This would be more simple, because I could code in html and not to write
program code
that generates html.

Thank you again.
Rolf Welskes
Aug 22 '06 #6
"Rolf Welskes" <ro**@nospam.nospamwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
This would be more simple, because I could code in html and not to write
program code that generates html.
Do you have a problem writing code...?
Aug 22 '06 #7
Thanks for your quick reply Rolf,

Though I'm not sure whether this is already added into the plan of next
version of ASPNET, it is really a good ideas to submit this request on our
feedback center:

#Visual Studio and .NET Framework Feedback
http://connect.microsoft.com/feedbac...spx?SiteID=210

Also, you can vote any other existing feedback there so that the product
team can get more comments and consider the update plan on the products.

Thanks again for your posting and feedback.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 22 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Moti | last post by:
I have SQL server 2000 which recently crashed. I try to recover it and found out that the Master database is corrupt. I never backup my server using inline sql backup nor any third party backup...
3
by: Sander Smeenk | last post by:
Hello! I'm trying to set up replication between two servers and even though I did everything according to the documentation, the slave keeps failing to connect to the master like this: |...
0
by: webhosting | last post by:
After a failure, we promoted a slave to master. This included renaming the server to the old master's name and ip address, but leaving the server id alone. The new master works fine. We...
1
by: HS1 | last post by:
Hello all - I have a master and a details table presented in two datagrid - I also have some text boxes that present the values from any record in the master table. This also helps to enter new...
0
by: Geoff Sullivan | last post by:
Are controls inside a nested master accessible? I have a master (b) which references another master (A). In master (b) I has several ASP controls. On the Page_Load of master (b), I can't seem to...
6
by: brian.j.parker | last post by:
I inherited an application (or two) that run on SQL Server 6.5, which I haven't used in years, and am having a problem. I get the error: ...
3
by: AmitKu | last post by:
My site has a header and footer that is common to all pages on the site. It makes sense that this should be stored within a master, and have everybody go off of this one. However, one part of...
2
by: John | last post by:
Hi I am trying to create a master/detail form. I have my master and details tables dragged onto the dataset. I have also dragged the fields from master table on the form which has created the...
2
by: hlnet | last post by:
I am newbie. I want use query : SELECT public.Master.ID, public.Master.Description from Master , but ->Error missing table Master .If use query : SELECT "public"."Master"."ID",...
4
by: harijay | last post by:
Hi I am new to writing module and object oriented python code. I am trying to understand namespaces and classes in python. I have the following test case given in three files runner , master and...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.