Thursday, March 22, 2012

Set Metadata in code-behind

Can one set your page meta data in your code behind?
For instance, this one page can display any of many companies.
I want to add a keywords, and description fiield in the database for a company.
When this page load, I want to set the page's metadata to what is in the database..so i have to do it in my code behind.

Currently, I do something like this:
<meta content="Nico Nel (Accuracy Automotive)" name="author">
<meta content="nico@dotnet.itags.org.accuracyauto.com" name="reply-to">
<% if (Language == "ja-JP") {%>
<meta content="Japanese Description." name="description">
<meta content="Japanese Keywords" name="keywords">
<LINK href="http://links.10026.com/?link=styles/style_ja.css" type="text/css" rel="stylesheet">
<%} else if (Language == "en-US") {%>
<meta content="English Description." name="description">
<meta content="English Keywords" name="keywords">
<LINK href="http://links.10026.com/?link=styles/style_en.css" type="text/css" rel="stylesheet">
<%} else {%>
<meta content="Chinese Description." name="description">
<meta content="Chinese Keywords" name="keywords">
<LINK href="http://links.10026.com/?link=styles/style_zh.css" type="text/css" rel="stylesheet">
<%}%>Set each of the <meta> tags to runat=server.
Give them an ID.

You can now access them from your codebehind.
Just like any control.
cool..thanks M.
Hmmm...as what do one declare them variables in your code?
(you know..like a table cell would be protected htlmtablecell mycell;)

0 comments:

Post a Comment