【发布时间】:2013-10-18 08:24:11
【问题描述】:
问题
- 如何在后台代码 (VB) 中设置母版页对象 id(例如 div id)?
- 如何更改子页面的id?
Root.Master
<%@ Master Language="VB" CodeFile="~/Root.master.vb" Inherits="Root"%>
<div id="<%=MyPage%>">
<asp:ContentPlaceHolder ID="Content" RunAt="Server"/>
</div>
Root.Master.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
Index.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
【问题讨论】:
-
object id是什么意思?喜欢this? -
特别是body id。
-
你为什么需要那个?你想应用一些 css 还是使用 javascripts?有什么具体原因吗?
-
我正在使用 jquery mobile 并且需要每个页面的 body id 都不同以利用其全部功能。使用母版页可以节省大量重复代码。
-
如果它只是一个 div。请参阅上面的编辑。这仍然对我有用。
标签: asp.net vb.net variables master-pages