Saturday, March 24, 2012

Web.Config setting in Page Header...

Hi all,

I am trying to use a setting in my web.config to add to my headers Meta data.

For example, I have the following code in my web config:

<!-- Site Meta Tags -->
<add key="MetaKeywords" value="xyz" />

And I want to add this to my page header:

<meta content="XYZ" name="keywords" />

I have tried a number of things, i.e.

<meta content="ConfigurationSettings.AppSettings("MetaKeywords")" name="keywords" />

etc.

Any ideas/help would be greatly appreciated.

Thanks in advance,

TCM_

you could switch it to a databind statement, or you could put a literal control in its place and set the literals text property from codebehind.

I prefer the literal control approach as i dont like to databind at the page level.

<meta content='<asp:Literal ID="keywords" runat="server"/>' name="keywords" />

then in codebehind:

keywords.Text = ConfigurationSettings.AppSettings("MetaKeywords")

0 comments:

Post a Comment