Change header info in Master Page (2.0)

S

sck10

Hello,

I have the following in my Master Page that I am using as a redirect
template:

<head id="headRedirect" runat="server">
<meta id="metaRedirect" http-equiv="Refresh" content="2;
URL=http://www.mysite.com/" />
<title>Page Redirect</title>
</head>

My question is how can I change the URL that is referenced in the meta data
from the content page? Also, Can you add meta data? With .NET 1.1 I could
use the following: Master.Page.Header.Metadata.Add("Keywords", "lws,services
technologies," & strTitle), but this doesn't seem to work in 2.0. Any
assistance with this would be greatly appreciated.

Thanks, sck10
 
S

Steven Cheng[MSFT]

Hello Steve,

I'm abit confused about the following things you mentioned:

=================
With .NET 1.1 I could
use the following: Master.Page.Header.Metadata.Add("Keywords",
"lws,services
technologies," & strTitle), but this doesn't seem to work in 2.0
==================

Master Page is only available in ASP.NET 2.0/.NET 2.0 but not 1.1, what's
the "1.1" you mentioned?


As for how to modify the <meta > tag's content field in code, I think you
can directly use the content page's Page.Header.FindControl to reference
the meta tag defined in master page(the Meta tags in master page will be
added into concrete page's Header.Controls at runtime). For example, for
your master page template(as below):

===========
<head id="headRedirect" runat="server">
<meta id="metaRedirect" http-equiv="Refresh" content="2;
URL=http://www.mysite.com/" />
<title>Page Redirect</title>
</head>
==============

In concrete page(applied the above master page), you can use the following
code to modify its content:

================
protected void Page_Load(object sender, EventArgs e)
{
HtmlMeta meta = Page.Header.FindControl("metaRedirect") as HtmlMeta;

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


Please feel free to let me know if the above code works or if you have any
other concerns.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top