Tài liệu giảng dạy về ASP.net đã được giảng dạy với mục đích cung cấp cho sinh viên những kiến thức cơ bản nhất, có tính hệ thống liên quan tới lập trình. Thông qua cuốn tài liệu này, chúng tôi muốn giới thiệu với các bạn đọc về kỹ năng lập trình cơ bản.Mời các bạn cùng tham khảo
Trang 1Môn học: Lập trình ASP.NET
ASP.NET Navigation
TRƯỜNG ĐẠI HỌC KHOA HỌC TỰ NHIÊN
KHOA CÔNG NGHỆ THÔNG TIN
BỘ MÔN CÔNG NGHỆ PHẦN MỀM
Trang 3
ASP.NET Navigation
quan tâm là việc xây dựng cấu trúc của Website (organization structure)
là sitemap
3
Trang 4XML Site map
4
Trang 5Site Navigation
Các Sitemap control dùng để hiển thị site map
5
Trang 6Site Navigation Schema
Site Navigation API
Trang 7XML Site map
định nghĩa cấu trúc website thông qua các external data source.
mapping này có thể là các XML file, database…
7
Trang 88
Trang 99
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="" title="" description="">
<siteMapNode url="~/Default.aspx" title="Trang Chủ" description="Trang Chủ" >
<siteMapNode url="~/Gallery.aspx" title="Gallery" description="Gallery" />
<siteMapNode url="~/ContactUs.aspx" title="Liên hệ" description="Liên hệ" />
</siteMapNode>
</siteMap>
Trang 11Cấu hình SiteMap File
Trang 12SiteMapPath Control
chủ) đến node hiện tại (breadcrumb)
12
Trang 13Stylizing SiteMapPath
<asp:SiteMapPath Font-Name="Verdana" Font-Size="10pt" RunAt="server">
<CurrentNodeStyle Height="24px" BackColor="Yellow" Font-Bold="true" />
Trang 14Key SiteMapPath Properties
CurrentNodeStyle Style used to render the current node
CurrentNodeTemplate HTML template used to render the current nodeNodeStyle
Trang 15Orientation="Horizontal" StaticDisplayLevels="2" StaticSubMenuIndent="10p
x
Trang 17Declaring a TreeView
<asp:TreeView RunAt="server>
<Nodes>
<asp:TreeNode Text="Training" RunAt="server">
<asp:TreeNode Text="Programming NET" RunAt="server"
Trang 18Key TreeView Properties
ShowExpandCollapse Specifies whether expand/collapse indicators are shownExpandDepth Specifies the TreeView's initial expand depth
LevelStyles Specifies appearance of nodes by level
RootNodeStyle Specifies appearance of root nodes
LeafNodeStyle Specifies appearance of leaf nodes
SelectedNodeStyle Specifies appearance of selected nodes
HoverNodeStyle Specifies appearance of nodes when cursor hovers overheadNodeStyle Specifies default appearance of nodes
Trang 19TreeViews and Site Maps
<asp:SiteMapDataSource ID="SiteMap" RunAt="server" />
<asp:TreeView DataSourceID="SiteMap" RunAt="server" />
<siteMap>
<siteMapNode title="Home" description="" url="default.aspx">
<siteMapNode title="Training" url="Training.aspx"
description="Training for NET developers">
<siteMapNode title="Programming NET" url="Classes.aspx?id=1"
description="All about the NET Framework" />
<siteMapNode title="Programming ASP.NET" url="Classes.aspx?id=2"
description="All about ASP.NET" />
<siteMapNode title="Programming Web Services" url="Classes.aspx?id=3" description="All about Web services" />
</siteMapNode>
</siteMap>
Web.sitemap
Trang 21Thay đổi Default sitemap file
Trang 22Security Trimming
<siteMap>
<siteMapNode title="Home" description="" url="default.aspx">
<siteMapNode title="Announcements" url="Announcements.aspx"description="Information for all employees" roles="*" />
<siteMapNode title="Salaries" url="Salaries.aspx"
description="Salary data" roles="Managers,CEOs" />
Trang 23Enabling Security Trimming
Trang 24Sử dụng đối tượng Sitemap
// Write the title of the current node to a Label control
Label1.Text = SiteMap.CurrentNode.Title;
// Write the path to the current node to a Label control
SiteMapNode node = SiteMap.CurrentNode;
StringBuilder builder = new StringBuilder (node.Title);
while (node.ParentNode != null) {