动态菜单可能仅一次调用母版页Page_Load事件?

时间:2019-02-15 01:01:51

标签: c# vb.net

我已从数据库动态加载“母版”页面中的“所有菜单”。 所以我想知道重定向到另一页面时只能为Master page page_load事件加载一次吗?

这是母版页菜单项代码的一部分

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If Session("WMPSlogin") <> "" Then
        lbluser.Text = Session("WMPSlogin")
        lblLuser.Visible = True
        lbluser.Visible = True
        hlLogin.Visible = True
    Else
        lblLuser.Visible = False
        lbluser.Visible = False
        hlLogin.Visible = False
    End If

    If Not IsPostBack Then
        Dim db As New clsDataBase

        Dim sqlmenu_item As String = "select menu_id, menu_item_name, menu_parent_id, Url, Selectable from navigation_menu_item "
        'db.OpenTable(sqlmenu_item)

        Dim dbtable As DataTable = db.getDataTable(sqlmenu_item)
        Dim viewItem As DataView = New DataView(dbtable)
        viewItem.RowFilter = "menu_parent_id = 0"

        For Each row As DataRowView In viewItem
            Dim menuItem As New MenuItem() With { _
             .Value = row("menu_id").ToString(), _
             .Text = row("menu_item_name").ToString(), _
              .NavigateUrl = row("Url").ToString(), _
                .Selectable = Convert.ToBoolean(row("Selectable").ToString()) _
            }
            Menu1.Items.Add(menuItem)
            AddChildItems(dbtable, menuItem)

        Next
        db.Close()
    End If
End Sub

0 个答案:

没有答案