假设我有一个包含一些用户控件的 Web 表单。我的“主要”Web 表单的标题标签是在其中一个用户控件中生成的。将此数据传递给 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 表单的名称。这是在 Main 中设置该值的 sub。
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 之外,还有其他人有什么想法吗?
通过在用户控件中创建属性,现在可以正确传递值。