473,396 Members | 2,013 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,396 software developers and data experts.

Controlling Title and Metatags when using MasterPage

Hi guys

I'm using a MasterPage for my website rebuild (vs2005, .net2, c#).

I want to be able to control the Title element, both on the MasterPage and
the Content pages. For example, on each page I want the following to appear
for the Title..

SITENAME - some page related title

Obviously, I could just code each page to have "SITENAME - " in, but I'm
trying to find a way of being able to do something like..

this.Title += "some page related title"

... where the "SITENAME - " part has been added by the MasterPage. Can't get
this to work though.. any ideas? If I add to the <title> element of the
MasterPage, then it gets over written by the content, and i end up with

"Untitled Pagesome page related title"

and if I add Page.Title in the MasterPage .cs, then that overrides the title
for the ContentPage, so I end up with

"SITENAME - "

Arrrrgh! Help much appreciated! :o) While were on the subject, how can I
change metadata (keywords, description, etc) for each Content page? Can I
just do that directly from the .cs?

Cheers
Dan
Jun 25 '06 #1
3 1196
Hi Dan,

Thank you for your post.

Based on my understanding, the questions are:
1) How to change page title of a content page while using master page?
2) How to add meta keywords from content page?
If I've misunderstood anything, please feel free to post here.

I think you can change the page title in the master page's PreRender event:

protected void Page_Load(object sender, EventArgs e)
{
PreRender += new EventHandler(MasterPage_PreRender);
}

void MasterPage_PreRender(object sender, EventArgs e)
{
Page.Title = "Master - " + Page.Title;
}

As for the meta keywords, there're several ways to achieve this, you can
find more information here:

#Master Pages: Tips, Tricks, and Traps
http://odetocode.com/Articles/450.aspx

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 26 '06 #2
Walter,

Thanks for the reply - just what I was looking for.

Cheers
Dan
"Walter Wang [MSFT]" wrote:
Hi Dan,

Thank you for your post.

Based on my understanding, the questions are:
1) How to change page title of a content page while using master page?
2) How to add meta keywords from content page?
If I've misunderstood anything, please feel free to post here.

I think you can change the page title in the master page's PreRender event:

protected void Page_Load(object sender, EventArgs e)
{
PreRender += new EventHandler(MasterPage_PreRender);
}

void MasterPage_PreRender(object sender, EventArgs e)
{
Page.Title = "Master - " + Page.Title;
}

As for the meta keywords, there're several ways to achieve this, you can
find more information here:

#Master Pages: Tips, Tricks, and Traps
http://odetocode.com/Articles/450.aspx

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 26 '06 #3
Hi Dan,

Appreciate your update and response. I am glad to hear that the problem has
been fixed. If you have any other questions or concerns, please do not
hesitate to contact us. It is always our pleasure to be of assistance.

Have a nice day!
Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 27 '06 #4

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

Similar topics

1
by: Alan Silver | last post by:
Hello, I am just experimenting with master pages, and am trying to add a content placeholder in the <head> section, so that individual pages can set their own page title and meta tags. The...
8
by: GaryDean | last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much in answers so I'm reposting some questions posted by some of the programmers here in our organization that never got...
3
by: Laith Zraikat | last post by:
I need to set the page title for a content page in a master page, and do that using local reources so that I can have my page title in different languages. I can do that easily using global...
4
by: Pitaridis Aristotelis | last post by:
Does anyone knows how to change the title of the page when someone uses a masterpage? Aristotelis
0
by: Tor Inge Rislaa | last post by:
Controlling the TreeView I have the sitemap below as source for my TreeView control. When I open my application I want only the nodes Home, About, Products and Contact to show. The child nodes...
0
by: Tor Inge Rislaa | last post by:
Controlling TreeView Expand/Collapse With a TreeView bound to an XML file as below I want to obtain the functionality where Chapter 2 and 3 are forced to collapse when Chapter 1 is...
3
by: Silmaril | last post by:
hi everyone, i have a question about place of metatags. i've started to seo for active webpage of our client(which is not coded by me) ,but website is very bad coded then i'm a lazy programmer...
1
by: Sinan Alkan | last post by:
In a master page --content page system, is it possible to change the "description" and "keywords" meta tags of the master page from content page ? I am trying as follows, from content page.... ...
0
by: thersitz | last post by:
Hi, Using aspnet3.5,VStudio 2008, VB 1.) I have a set of pages, with a search text box button within a userControl that searches across our websites and is registered in a masterpage. 2)...
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: 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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...

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.