QBall777
08-21-2009, 05:12 PM
Hi
I'm attempting to add meta tags dynamically from my sql db.
On the master.page I get the data using an <asp:sqlDataSource>
But in the code behind I'm unsure how to apply this.
htmMeta.Attributes.Add("content", "'<%# MetaTitle %>'");
//Find the Head Tag in Master Page
HtmlHead hdMain = (HtmlHead)Page.Master.FindControl("mainHead");
HtmlMeta htmMeta = new HtmlMeta();
htmMeta.Attributes.Add("name","description");
htmMeta.Attributes.Add("content", "'<%# MetaTitle %>'");
//Add Meta Tag to Head
hdMain.Controls.Add(htmMeta);
//Adding keyword Meta Tag to Head Section
HtmlMeta hm2 = new HtmlMeta();
hm2.Attributes.Add("name", "keywords");
hm2.Attributes.Add("content", "Here you can pass your keywords");
hdMain.Controls.Add(hm2);
Hope someone can help.
Thanks
I'm attempting to add meta tags dynamically from my sql db.
On the master.page I get the data using an <asp:sqlDataSource>
But in the code behind I'm unsure how to apply this.
htmMeta.Attributes.Add("content", "'<%# MetaTitle %>'");
//Find the Head Tag in Master Page
HtmlHead hdMain = (HtmlHead)Page.Master.FindControl("mainHead");
HtmlMeta htmMeta = new HtmlMeta();
htmMeta.Attributes.Add("name","description");
htmMeta.Attributes.Add("content", "'<%# MetaTitle %>'");
//Add Meta Tag to Head
hdMain.Controls.Add(htmMeta);
//Adding keyword Meta Tag to Head Section
HtmlMeta hm2 = new HtmlMeta();
hm2.Attributes.Add("name", "keywords");
hm2.Attributes.Add("content", "Here you can pass your keywords");
hdMain.Controls.Add(hm2);
Hope someone can help.
Thanks