0
我們想操作來自不同網頁的母版頁中的ASP.Net TreeView。操作來自不同網頁的母版頁中的ASP.Net TreeView
此編碼來自主頁面web表單代碼隱藏文件。我們希望在另一個網頁的代碼隱藏文件的Page_Load事件中複製此代碼。當我嘗試在其他Web表單中使用此編碼時,我們得到一個錯誤,指出loginView受到保護。我們如何取消它的保護,以便我可以複製相同的編碼?
這裏是從主網頁表單代碼隱藏文件的工作編碼:
Public Class Knowledge_Academy1
Inherits System.Web.UI.MasterPage
Protected Sub TreeViewMain_TreeNodeExpanded(sender As Object, e As TreeNodeEventArgs)
Dim objTreeView As TreeView
objTreeView = loginView.FindControl("TreeViewMain")
Select Case e.Node.Text
Case "Maintenance"
' Make sure all nodes except for Maintenance are collapsed.
'----------------------------------------------------------
For Each treenode As TreeNode In objTreeView.Nodes
If treenode.Text = "Parents" Or
treenode.Text = "Students" Or
treenode.Text = "Financial" Then
treenode.Collapse()
End If
Next treenode
Case "Students"
' Make sure all nodes except for Students are collapsed.
'-------------------------------------------------------
For Each treenode As TreeNode In objTreeView.Nodes
If treenode.Text = "Parents" Or
treenode.Text = "Maintenance" Or
treenode.Text = "Financial" Then
treenode.Collapse()
End If
Next treenode
Case "Parents"
' Make sure all nodes except for Parents are collapsed.
'------------------------------------------------------
For Each treenode As TreeNode In objTreeView.Nodes
If treenode.Text = "Students" Or
treenode.Text = "Maintenance" Or
treenode.Text = "Financial" Then
treenode.Collapse()
End If
Next treenode
Case "Financial"
' Make sure all nodes except for Financial are collapsed.
'--------------------------------------------------------
For Each treenode As TreeNode In objTreeView.Nodes
If treenode.Text = "Parents" Or
treenode.Text = "Maintenance" Or
treenode.Text = "Students" Then
treenode.Collapse()
End If
Next treenode
Case Else
End Select
End Sub
感謝您的快速回復和有用的提示。我將研究鏈接中的內容以瞭解如何去做。 – 2013-02-11 14:32:11
太棒了,我喜歡它,當Stackoverflow有這樣的成員! – 2013-02-11 21:27:43
Stackoverflow非常有幫助,這是因爲我從每個提供答案的人那裏得到了很多幫助。 :-) – 2013-02-12 14:56:57