473,408 Members | 1,702 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,408 software developers and data experts.

changing the metatags of masterpage from content page

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....

protected void Page_Load(object sender, EventArgs e)
{
HtmlMeta fordesc = new HtmlMeta();
fordesc.Name = "keywords";
fordesc.Content = "word1, word2, word3";
Header.Controls.Add(fordesc);
}

But it adds second "keywords" metatag sentence to the page .
How can i just replace or change tags of the master-pages's ?

Thanks in advance...

PS: I'm using c# and framework 2.0
Sep 17 '08 #1
1 1852
I don't know a whole lot about metatags, but I do know that the Add method
is used for appending to a collection, not replacing individual items. What
you basically need to do if you want to replace the metatags is one of the
following:

1. Don't include any metatags in the master page itself, and add all of them
dynamically in the content pages

2. Call the Header.Controls.Clear() method before dynamically adding the
metatags in the content page

3. In the master page's metatags include id and runat="server" attributes so
that you can remove them before adding another metatag in the content page

Note that when using the first two options you will need to add ALL metatags
in the content page. Hopefully this helps.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Sinan Alkan" <DL@DL.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
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....

protected void Page_Load(object sender, EventArgs e)
{
HtmlMeta fordesc = new HtmlMeta();
fordesc.Name = "keywords";
fordesc.Content = "word1, word2, word3";
Header.Controls.Add(fordesc);
}

But it adds second "keywords" metatag sentence to the page .
How can i just replace or change tags of the master-pages's ?

Thanks in advance...

PS: I'm using c# and framework 2.0


Sep 17 '08 #2

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

Similar topics

2
by: dawg1998 | last post by:
I have a page that creates dynamic textboxes based on the number of fields a user chooses to fill out. This process worked great when the page was standalone. However, when I move to a...
2
by: K B | last post by:
Hi, I created a simple MasterPage, then created a content page. I've checked that my MasterPage HTML is correct, but when I run the content page, I get a blank page in IE. My content page is...
3
by: musosdev | last post by:
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...
6
by: =?Utf-8?B?QmVuIFIu?= | last post by:
Hi, WHen I specify my master page in the page's @Page directive, no problems. However, when I put it ias an attribute in Web.config's page element, the designer fails. It just says "Error...
7
by: Bon | last post by:
Dear all I create a master page with image buttons on the left-hand side for navigation. When a user clicks the student button, the content (i.e. ContentPlaceholder) in masterpage will be...
8
by: Randy Smith | last post by:
Hi, I now need to add MasterPages to a number of existing forms, but when I add the code for MasterPage, the MasterPage does NOT appear when it runs. Any thoughts? TIA, Randy Smith
4
by: Torben Laursen | last post by:
I want to change the label of a component that I have on a masterpage but I cannot get my hands on it I have a mastepage MP2 that has a button called B2 masterpage MP2 uses masterpage MP1 that has...
0
by: Tommy Jakobsen | last post by:
Hi. Is there a problem when trying to use Javascript on a nested masterpage? On my masterpage, i've got this in the <head>: <asp:ContentPlaceHolder ID="HeadContent" runat="server" /> And on...
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: 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?
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...
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,...
0
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...

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.