dinsdag, juli 18, 2006

 

Dynamic metadata

Saw some plp asking how to set metadata dynamically, well here the answer:

//*** page title ***
this.Page.Title = "http:\\dotnetpret.blogspot.nl";

myHeadDummy.Text = "\n";
this.Page.Header.Controls.Add(myHeadDummy);

//*** page keywords ***
HtmlGenericControl Keywords = new HtmlGenericControl("meta");
Keywords.Attributes.Add("NAME", "Keywords");
Keywords.Attributes.Add("CONTENT", "c#,.Net,dotnet,ASP.NET")
this.Page.Header.Controls.Add(Keywords);


//*** page description ***
HtmlGenericControl Description = new HtmlGenericControl("meta");
Description.Attributes.Add("NAME", "Description");
Description.Attributes.Add("CONTENT", 'if its .net its here");
this.Page.Header.Controls.Add(Description);