开发者

access children page's title from masterpage aspx

开发者 https://www.devze.com 2023-02-15 17:05 出处:网络
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

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开发者_JAVA百科 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?


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

'Do some stuff here

End Sub

End Class


try using Dim varTitle = this.Title

or if you are using a script

var title = window.title
0

精彩评论

暂无评论...
验证码 换一张
取 消