views:

735

answers:

1

Let's say I have a web form that includes some user controls. The title tag for my "main" web form is generated in one of the user controls. Passing this data to the web form is currently done like this.

Public Sub SetPageValues(ByVal sTitle As String, ByVal sKeywords As String, ByVal sDesc As String)
    MySystem.Web.UI.Main.PageSettings(sKeywords, sDesc, sTitle)
End Sub

Main is the name of the web form. Here's the sub that sets that values in Main.

 Public Shared Sub PageSettings(ByVal strKeywords As String, ByVal strDesc As String, ByVal strTitle As String)
    Dim _lblTitle As System.Web.UI.webcontrols.Literal = lblTitle
    Dim _lblMetaDesc As System.Web.UI.webControls.Literal = lblMetaDesc
    Dim _lblMetaKeywords As System.Web.UI.WebControls.Literal = lblMetaKeywords
    Dim _lblMetatitle As System.Web.UI.WebControls.Literal = lblMetaTitle
    _lblTitle.Text = strTitle
    _lblMetaDesc.Text = "<meta name=""description"" content=""" + strDesc + """>"
    _lblMetaKeywords.Text = "<meta name=""keywords"" content=""" + strKeywords + """>"
    _lblMetatitle.Text = "<meta name=""title"" content=""" + strTitle + """>"
End Sub

After all of this we are running pooled memory and recycle it every 400 minutes, however, page titles get corrupted and display incorrectly. Does anyone have any ideas other than moving to a new version .net?

By making properties in the user control, the values can now be passed correctly.

+1  A: 

Personally, here's what I would do. First - Change the TITLE to an HTML.GenericControl On the ASPX side, it would look like this:

<title runat="server" id="title" />

Then, I'd modify the META tags to also be html generic controls

<meta name="description" content="description" id="description" runat="server" />
<meta name="keywords" content="keys" id="keywords" runat="server" />

At that point, you can modify the values like this:

title.InnerText = "This Title"
keywords.Attributes("content") = "key,word"
description.Attributes("content") = "A demonstration of Setting title and meta tags"
Stephen Wrighton