我有一堆与 VB.NET
中的同一母版页相关的子页面。
现在我需要根据子页面的标题更新数据库记录,并且由于项目中每个页面的隐藏代码都是相同的,所以我想将这些内容放在母版页中。
每个页面都有自己的 title="myOwnTitle"
属性,如下所示:
但是当我在母版页级别编写脚本时就像:
Dim varTitle = me.Title
实际返回的值是母版页标题(当然你会说:-)
是否有一个简单的解决方案可以从母版访问子页面?
I have a bunch of child pages relating to the same masterpage in VB.NET
.
Now I need to update database records depending upon child page's title, and since the code-behind is the same for each page in the project, I want to put that stuff in the master page.
Each page have its own title="myOwnTitle"
property like this: <Page%@ Page Title="Test Page"
But when I write a script on the masterpage level like:
Dim varTitle = me.Title
The value that is actually returned is the masterpage title (of course you'd say :-)
Is there a SIMPLE solution to access the children page from master?
发布评论
评论(2)
必须在母版页中吗?当我在每个子页面中执行常见任务时,我会创建一个继承自 Page 的新类并将其用于我的子页面。
公开课新页
继承System.Web.UI.Page
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) 处理Me.Load
End Sub
End Class
Does it have to be in the master page? When I have common tasks to do in each child page then I make a new class that inherits from Page and use that for my children pages.
Public Class NewPage
Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
End Class
尝试使用
Dim varTitle = this.Title
或者如果您使用的是脚本
try using
Dim varTitle = this.Title
or if you are using a script