0
以下面的web.sitemap爲例,我們希望創建一個事件處理程序來捕捉用戶何時單擊「教師」鏈接ASP.Net TreeView。這恰好是一個父節點。當用戶點擊ASP.Net TreeView的節點時使用的事件處理程序
<siteMapNode title="Teachers" url="~/DefaultTeachers.aspx" >
<siteMapNode url="~/Teachers.aspx" title="Teachers" description="Maintain details of each Teacher." />
<siteMapNode url="~/TeacherSchedules.aspx" title="Teacher Schedules" description="Maintain teacher schedules." />
<siteMapNode url="~/TeacherEmailNotices.aspx" title="Email Notices To Teachers" description="Email notices to teachers." />
</siteMapNode>
你能告訴我在ASP.Net的TreeView的標記放置什麼事件,也許這樣的事情?
<asp:TreeView
id="TreeViewMain"
runat="server"
ExpandDepth="0"
OnUserClickedTheLink="TreeViewMain_UserClickedTheLink"
DataSourceID="KnowledgeAcademySiteMap">
<RootNodeStyle ImageUrl="/Images/book.png" />
<ParentNodeStyle ImageUrl="/Images/book.png" />
<LeafNodeStyle ImageUrl="/Images/book.png" />
</asp:TreeView>
在
而且代碼隱藏文件,我們想向e.Node或類似的東西在一個「如果」語句來測試哪個節點實際被點擊:
If e.Node.Text = "Teachers" Then
' We will close all other nodes and open up the 3 leaf nodes under "Teachers" here.
'----------------------------------------------------------------------------------
End If
這將不被接受感謝回覆和有用的代碼示例。 :-) –