0

いくつかのユーザー コントロールを含む Web フォームがあるとします。「メイン」Web フォームのタイトル タグは、ユーザー コントロールの 1 つで生成されます。このデータを Web フォームに渡すことは、現在このように行われています。

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 は Web フォームの名前です。メインでその値を設定するサブは次のとおりです。

 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

このすべての後、プールされたメモリを実行し、400 分ごとにリサイクルしますが、ページ タイトルが破損し、正しく表示されません。新しいバージョンの .net に移行する以外のアイデアはありますか?

ユーザー コントロールにプロパティを作成することで、値を正しく渡すことができるようになりました。

4

1 に答える 1

1

個人的には、ここで私がやりたいことです。まず、TITLE を HTML.GenericControl に変更します。ASPX 側では、次のようになります。

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

次に、META タグを変更して、html 汎用コントロールにもします。

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

その時点で、次のように値を変更できます。

title.InnerText = "This Title"
keywords.Attributes("content") = "key,word"
description.Attributes("content") = "A demonstration of Setting title and meta tags" 
于 2008-09-29T14:08:42.693 に答える