I am beginner in .NET. One of my firsts task is to change the meta tags dynamically for dynamically generated pages.
So, I came up with this, but am not too sure on what is considered the "proper" way to do it in .NET.
<head>
<title><%= title %></title>
<meta name="description" content="<%= MetaDescription %>" />
...
</head>
This function lives in my masterpage codebehind and I set a default title, etc on page init (not shown below)
Protected Title As String = ""
Public Sub ChangeTitle(ByVal title As String)
Title = title
End Sub
I also called this function in any product detail pages to set the appropriate dynamic title.
Is that considered ok in NET? Is this not good or hackish or would you say "if it works, works?
I tried adding runat="server" to the head tag, to use Page.title but then once that got added in, this line <meta name="description" content="<%= MetaDescription %>" />
gets decoded to
<meta name="description" content="<%= MetaDescription %>" />
and my code above then doesn't work to change the meta description.