我有一个网站,它的代码几乎可以生成页面上的所有内容。主页包含一个通过代码构建的右侧菜单。它使用 System.Web.UI.WebControls.TableCell 类并为每个新项目创建一个 td。
这是代码片段:
Public Sub BuildMainMenuStructure(ByVal Cell As TableCell, _
ByVal Contents As DataTable, _
ByVal ReadMode As Boolean, _
ByVal CurrentPage As String, _
ByVal RecSecurity As ApplicationRoleSecurity, _
ByVal SourcePageRef As Integer, _
ByVal IncludeMyIntranetPanel As Boolean)
'-----------------------------------------------------------------
'Div1 Contents
'-----------------------------------------------------------------
'Set up the contents in a div (panel) called pnlMainMenu1
Dim mmContents As New MainMenuContents
mmContents.ID = "pcaMainMenuContents"
mmContents.SetControl(Contents, _
ReadMode, _
CurrentPage, _
RecSecurity, _
SourcePageRef)
mintContentsCount = mmContents.Count
Dim pnlMainMenu1 As New Panel
With pnlMainMenu1
.ID = "pcaMainMenuContentsPanel"
'By default, this panel is visible:
.Style.Add("visibility", "visible")
.Controls.Add(mmContents)
End With
在代码的另一个区域中,生成了主页的不同部分:
If IncludeMyIntranetPanel And ReadMode Then
'Set up the contents in a div (panel) called pnlMainMenu2
Dim mmMyIntranet As New MainMenuMyIntranet
mmMyIntranet.ID = "pcaMainMenuMyIntranet"
mmMyIntranet.SetControl(Contents, _
ReadMode, _
CurrentPage, _
RecSecurity, _
SourcePageRef)
Dim pnlMainMenu2 As New Panel
With pnlMainMenu2
.ID = "pcaMainMenuMyIntranetPanel"
'By default, this panel is visible:
.Style.Add("visibility", "visible")
.Controls.Add(mmMyIntranet)
End With
'Add it to the cell:
Cell.Controls.Add(pnlMainMenu2)
End If 'End If IncludeMyIntranetPanel
它通过 Cell.Controls.Add(pnlMainMenu2) 添加内容
我的任务是尝试重新设计主页。理想情况下,我想生成 DIV 类,以便轻松定位内容。
是否有一个我可以使用的 .net 类从数据库中获取数据并创建 div 类?