问题
- 如何在代码后面(VB)中设置母版页对象ID(例如div id)?
- 如何更改子页面中的id?
根主
<%@ Master Language="VB" CodeFile="~/Root.master.vb" Inherits="Root"%>
<div id="<%=MyPage%>">
<asp:ContentPlaceHolder ID="Content" RunAt="Server"/>
</div>
根主.vb
Partial Class Root
Inherits BaseMaster
End Class
Page.vb(在 App_Code 文件夹中)
Public Class BaseMaster
Inherits System.Web.UI.MasterPage
Public MyPage As String
End Class
索引.aspx.vb
Partial Class Index
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
CType(Me.Master, BaseMaster).MyPage = "Page"
End Sub
End Class