by David Kiff
8. July 2007 13:41
A few people have asked me how to create a crumbline based on the URL, for example:
www.mydomain.com/Hello_World/MyPage.aspx
www.mydomain.com/DotNet/Examples/FirstExample.aspx
The first one should display:
Home > Hello_World > MyPage.aspx
Second should display:
Home > DotNet > Examples > FirstExample.aspx
Here is a method for doing so:
private string CreateCrumb()
{
string[] pathNames = Request.RawUrl.Split(‘/’);
System.Text.StringBuilder crumbLine = new System.Text.StringBuilder();
for (int i = 1; i < pathNames.Length; i++)
{
crumbLine.Append(pathNames.GetValue(i));
if (i != pathNames.Length - 1)
{
crumbLine.Append(" > ");
}
}
return crumbLine.ToString();
}
d08346b1-05e6-4352-ac47-62c29c7ef926|0|.0
Tags: