Preferred Language:
Listing 5.15 - MetaContent.aspx
Illustrates how to change the meta tags within a master page.
<%@ Page Language="C#" MasterPageFile="SimpleMaster.master" %>
<script runat="server">
void Page_Load()
{
// Create Meta Description
HtmlMeta metaDesc = new HtmlMeta();
metaDesc.Name = "DESCRIPTION";
metaDesc.Content = "A sample of using HtmlMeta controls";
// Create Meta Keywords
HtmlMeta metaKeywords = new HtmlMeta();
metaKeywords.Name = "KEYWORDS";
metaKeywords.Content = "HtmlMeta,Page.Header,ASP.NET";
// Add Meta controls to HtmlHead
HtmlHead head = (HtmlHead)Page.Header;
head.Controls.Add(metaDesc);
head.Controls.Add(metaKeywords);
}
</script>
<asp:Content
ID="Content1"
ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
Content in the first column
<br />Content in the first column
<br />Content in the first column
<br />Content in the first column
<br />Content in the first column
</asp:Content>
<asp:Content
ID="Content2"
ContentPlaceHolderID="ContentPlaceHolder2"
Runat="Server">
Content in the second column
<br />Content in the second column
<br />Content in the second column
<br />Content in the second column
<br />Content in the second column
</asp:Content>
ASP.NET 3.5 Unleashed
- Containing almost 2,000 pages of code samples and in-depth explanation of the
ASP.NET 3.5 Framework, ASP.NET 3.5 Unleashed is the most comprehensive book
written on the ASP.NET 3.5 Framework.
ASP.NET 3.5 Unleashed is now available in your local bookstore and online (Published January 7, 2008).
All of the code samples from this book are hosted "live" at this website.
Click here
to view the table of contents and code samples.