【发布时间】:2011-08-06 15:48:22
【问题描述】:
我很想在一个模块中使用以下过程来设置我的页面的标题、关键字等。
Public Shared Sub SetTitle(ByVal Heading As String, ByVal Keywords As String())
Dim myMaster As Masterpage = DirectCast(Me.Master, Masterpage)
If Request.QueryString("lng") = "es" Then
myMaster.MasterHeading = Heading
myMaster.MetaTitle = Heading
myMaster.MetaDescription = ""
myMaster.MetaKeywords = GetKeywords(Keywords)
End If
myMaster.MetaTitle = myMaster.MasterHeading
End Sub
问题是我得到了两个错误。
在Me.Master 我得到'Me' is valid only within an instance method. 错误并且在
If Request...我得到错误
Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class.
那么我该如何解决这些问题?我希望将这个程序放在一个共同的地方,而不是在每个页面中。
提前谢谢你。
【问题讨论】:
标签: asp.net vb.net module master-pages