473,394 Members | 1,932 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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 2173
"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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.