Friday, February 8, 2013

How to make sitemap and breadcumb?

public static void Createsitemap(string path)



{

XmlDocument xmldoc = new XmlDocument();

System.Text.StringBuilder sp = new System.Text.StringBuilder();

sp.Append("<?xml version='1.0' encoding='utf-8'?>");

string defaultURL = "Home";

string defaultTitle = "Home";

sp.Append("<siteMap>");

sp.Append("<siteMapNode url='" + defaultURL + "' title='" + defaultTitle + "'>");
string sturl = "";

string statictitle = "";
sturl = "About-Us.aspx";

statictitle = "About Us";

sp.Append("<siteMapNode url='" + sturl + "' title='" + statictitle + "'/>");

sturl = "ContactUs.aspx";

statictitle = "Contact Us";

sp.Append("<siteMapNode url='" + sturl + "' title='" + statictitle + "'/>");

sp.Append("</siteMapNode>");

//Fixed url complete ....................

sp.Append("</siteMapNode>");

sp.Append("</siteMap>");



xmldoc.LoadXml(sp.ToString());
 


xmldoc.Save(ConfigurationManager.AppSettings["SiteMap"] + path);

===========
in web.config
=======
<siteMap defaultProvider="XmlSiteMapProvider" enabled="true">

<providers>

<add name="XmlSiteMapProvider" description="SiteMap provider which reads in .sitemap XML files." type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" siteMapFile="~/admin/web.sitemap" securityTrimmingEnabled="true"/>

   

</providers>

</sitemap>

==================

in asp.net design
=========
<asp:TreeView ID="TreeView1" LeafNodeStyle-ImageUrl="~/images/dot.jpg"

runat="server" ExpandDepth="1" DataSourceID="SiteMapDS"

>

<NodeStyle VerticalPadding="2" Font-Names="Verdana" Font-Size="8pt" NodeSpacing="1" HorizontalPadding="5" ForeColor="Black" />

<HoverNodeStyle BackColor="#CCCCCC" BorderColor="#888888" BorderStyle="Solid" BorderWidth="1px" Font-Underline="true" />

<SelectedNodeStyle BackColor="White" VerticalPadding="1" BorderColor="#888888" BorderStyle="Solid" BorderWidth="1px" HorizontalPadding="3" />




 
</asp:TreeView>

<asp:SiteMapDataSource ID="SiteMapDS" runat="server" SiteMapProvider="XmlSiteMapProvider"/>

====================
for bread crumb
=========================


ascx file



===
Default provider automatic fetch from web.config
===
<%@ Control Language="C#" AutoEventWireup="true" EnableViewState="false" CodeFile="BreadCrumb.ascx.cs" Inherits="UserControls_BreadCrumb" %>



 
 
<asp:SiteMapPath ID="SiteMapPath1" runat="server" SkipLinkText=" " PathSeparator=">" PathSeparatorStyle-CssClass="PathSeparator" >

<NodeTemplate>

<a href='<%# Eval("url") %>'>

            <%# Eval("title") %>

</a>

</NodeTemplate>

<CurrentNodeTemplate>

<span class="blue-text"> <%# Eval("title") %></span>

</CurrentNodeTemplate>

</asp:SiteMapPath>

==================
for calling in master page on top
<%@ Register Src="BreadCrumb.ascx" TagName="BreadCrumb" TagPrefix="uc3" %>


====
put in proper place
======
<uc3:BreadCrumb ID="BreadCrumb" runat="server" />

 

1 comment: