| |
|
What is a SiteMapPath control in ASP.NET 2.0?
An asp:SiteMapPath control is a Navigation Control that comes along with the ASP.NET 2.0
framework. The sitemappath control consists site link's data in XML format. The emergence
of the Sitemappath control in ASP.NET 2.0 has totally eliminated the clumsy code used in bread
crumbs by veteran web developers in Classic ASP and ASP.NET 1.1. These bread crumbs
were comparatively tougher to maintain.
Now say you need to maintain a Sitemap of a Site having the following links...
Home
Products
Medicines
Soaps
Alcohol
Support
Phone Support
Email Support
Contact Us
Instead of hard coding these links inside your code, all this information may be maintained in an XML based Web.sitemap
file which can be bind to an asp:SiteMapPath control, and this would display like a website breadcrumb. Easier
than before!
The SiteMapPath control's SiteMapProvider property is used to set the site's sitemap provider. This
sitemap provider is another control called asp:XmlDataSource control. This needs to be registered in the
web.config file. If the SiteMapProvider property is not specified, then the default SiteMap Provider
information is picked up from the web.config file.
Note:The other two navigation controls in ASP.NET 2 are the Menu control and the TreeView control.
The XmlDataSource control loads an XML file that is specified using the DataFile property. This
control inherits from the HierarchicalDataSourceControl class.
Example XML below:
<asp:SiteMapPath ID="smm1" runat="server" SiteMapProvider="xds1"></asp:SiteMapPath>
<asp:XmlDataSource ID="xds1" DataFile="somefile.xml" runat="server"></asp:XmlDataSource>
If DataFile is not used in the XmlDataSource, the siteMapFile property can be set in the web.config.
In order to specify XML Data Source in web.config, see below:
<configuration>
<system.web>
<siteMap defaultProvider="XmlSiteMapProvider" enabled="true">
<providers>
<clear/>
<add name="XmlSiteMapProvider"
<description="Default SiteMap provider"
<type="System.Web.XmlSiteMapProvider"
<siteMapFile="~/Web.sitemap"
</>
</providers>
</siteMap>
</system.web>
</configuration>
Bind data to a server control without writing code
Masterpage ContentPage
Nested Masterpage?
SiteMapPath control
Sort GridView
Hotspot class, ImageMap
Update Delete Gridview, Datakeynames
| |