Tuesday, August 23, 2011

Dynamic Metatag In Master Page

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
        MasterPage myMaster = (MasterPage)this.Master;
        myMaster.MetaTitle = "This is the new Page Title, which is set upon Page_Load";
        myMaster.MetaDescription = "Hitendra";
        myMaster.MetaKeywords = "new, page, keywords, set, upon, page, load";

head id="Head1" runat="server">
title id="PageTitle" runat="server">This is the Default Page Title...</title>
meta name="Keywords" id="PageKeywords" content="default, page, keywords" runat="server" />
meta name="Description" id="PageDescription" content="This is the Default page desctription, which should be changed when the page is loaded." runat="server" />