Click here to Skip to main content
15,921,028 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys,

I have one question.

How do I data bind the value in meta tag using asp.net and C# backend sql server?

I Expect to do it dynamically using meta tag.

Please help me.

Thanks and Regards.

Nagarajan P.
Posted
Updated 13-Mar-11 23:06pm
v2
Comments
Dalek Dave 14-Mar-11 5:06am    
Edited for Spelling, Grammar and Readability.

Hi
C#
HtmlMeta des = new HtmlMeta();
des.Name = "description";
des.Content = Meta_Description;
Header.Controls.Add(des);


HtmlMeta is from the namespace System.Web.UI.HtmlControls

This question has the answer for you.

http://www.codeproject.com/Questions/167720/Adding-meta-tag-dynamically-to-aspx-pages.aspx
 
Share this answer
 
Comments
Dalek Dave 14-Mar-11 5:06am    
Good Call.
Albin Abel 14-Mar-11 6:27am    
Thanks Dalek Dave
C#
HtmlHead head = this.Page.Header;

//--<meta name="title" content="your title" />
HtmlMeta meta= new HtmlMeta();
meta.Attributes.Add("name", "title");
meta.Attributes.Add("content","your title");
head.Controls.Add(meta);

//--<meta name="title" content="car,books,games" />
meta = new HtmlMeta();
meta.Attributes.Add("name", "keywords");
meta.Attributes.Add("content", "car,books,games");
head.Controls.Add(meta);

//--<meta name="description" content="your site description" />
meta = new HtmlMeta();
meta.Attributes.Add("name", "description");
meta.Attributes.Add("content","your site description");
head.Controls.Add(meta);

Thanks
Internet Marketing
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900