Establish site navigation hierarchy in asp.net 2.0

Source: Internet
Author: User

The site navigation provider in the site navigation provider--asp.net2.0 exposes navigation information for pages in the application, allowing you to define the structure of the site separately, regardless of the actual physical layout of the page. The default site navigation provider is xml-based, but you can also expose the information from any back-end location by writing a custom provider.

The site navigation api--site Navigation API is used to access site navigation information in the application's code, which extracts the details of the navigation information store. You can use APIs to programmatically access the application's navigation nodes.

Navigation controls-navigation controls provide a common UI for navigating between pages, such as tree views, menus, and breadcrumb ("breadcrumbs", a control that displays the current page). These controls use the site navigation service in asp.net2.0 to retrieve the structure you have defined for your site. The SiteMapDataSource control also allows you to bind other UI controls to site navigation data.

Web sites often need to display navigation data to guide users on how to use the site. Asp. NET allows developers to simply define navigation data and to display the UI based on that information.

The site Navigation API is a provider-based (provider) programming content that is used to access site navigation data. The API stores navigation data in an XML file and exposes the data through a set of SiteMapNode classes. Application and control developers can build SiteMapNode instances and use this information to display the navigation interface.

Navigation-oriented server controls include menu, TreeView, SiteMapPath, and SiteMapDataSource controls. These controls are built at the top of the site navigation class, and they use and display navigation data regardless of the specific details of the data store. The menu and TreeView controls can also use data from XML files and XmlDataSource controls.

The URL mapping attribute allows developers to define simple rules for the remapping (re-mapping) of different URL requests.

Using Site navigation controls

The Menu, TreeView, SiteMapPath, and SiteMapDataSource controls generate navigation interfaces based on navigation data. Navigation data can be stored in an XML file, or by leveraging the capabilities of the site navigation feature based on the provider. The following example shows how to combine different controls that use site navigation features.

Building an application Site map

The example navigation structure is stored in the Web.sitemap file, where you can see the sitemap file. The Web.sitemap file contains a top-level element. Nesting at least one element within the element. You must have a top-level within a site map. The site navigation feature requires a root to ensure that access along the node hierarchy eventually converges to a known node. You can nest multiple elements under the root element. In addition, the depth of the nested element is unrestricted.

A element typically contains a URL (link), title (title), and description (description) attribute. The URL property indicates the path that corresponds to the page in the application. It can also contain the path to a page in another application, or to multiple URLs for a completely different Web site. In the following example, all URL properties use the application-relative syntax to refer to the path. The Title property is used to display the text content of the navigation data UI. For example, the SiteMapPath control displays the title property as the hyperlink text for the control. If the Description property is provided, the server control displays as a ToolTip or alt text. Developers can also add custom attributes to , using the default indexer (indexer) of the SiteMapNode class to retrieve these properties. You can check it out. NET Framework component documentation to find more information about some other properties of the element.

The content of Web.sitemap

以下是引用片段:
<siteMap>
<siteMapNode title="Home" url="~/default.aspx" >
<siteMapNode title="Introduction to ASP.NET" url="~/introduction/default.aspx">
<siteMapNode title="What's New in Whidbey?" url="~/introduction/whatsnew.aspx"/>
<siteMapNode title="Sample Applications (Starter Kits)" url="~/introduction/starterkits.aspx"/>
<siteMapNode title="Introduction to Visual Web Developer" url="~/introduction/vwd.aspx"/>
</siteMapNode>
<siteMapNode title="Building A Web Application" url="~/development/default.aspx">
<siteMapNode title="Building a Simple Application" url="~/development/simple/default.aspx">
<siteMapNode title="Introduction to ASP.NET pages" url="~/development/simple/pages.aspx"/>
……
</siteMapNode>
</siteMapNode>
</siteMap>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.