Omskrive vb til c#
http://aspnet.4guysfromrolla.com/articles/030806-1.aspxSub Page_Load(ByVal sender As Object, ByVal e As EventArgs) _
Handles Me.Load
'Create the bulleted list
bulletedList.Text = _
String.Format("<ul><li><a href=""{0}"">{1}</a></li>{2}</ul>", _
SiteMap.RootNode.Url, SiteMap.RootNode.Title, _
DisplaySiteMapLevelAsBulletedList())
End Sub
Private Function DisplaySiteMapLevelAsBulletedList() As String
'Get the SiteMapDataSourceView from the siteMapData SiteMapDataSource
Dim siteMapView As SiteMapDataSourceView = _
CType(siteMapData.GetView(String.Empty), SiteMapDataSourceView)
'Get the SiteMapNodeCollection from the SiteMapDataSourceView
Dim nodes As SiteMapNodeCollection = _
CType(siteMapView.Select(DataSourceSelectArguments.Empty), _
SiteMapNodeCollection)
'Recurse through the SiteMapNodeCollection...
Return GetSiteMapLevelAsBulletedList(nodes)
End Function
Private Function GetSiteMapLevelAsBulletedList(ByVal nodes As _
SiteMapNodeCollection) As String
Dim output As String = String.Empty
For Each node As SiteMapNode In nodes
output &= String.Format("<li><a href=""{0}"">{1}</a>", _
node.Url, node.Title)
'Add any children levels, if needed (recursively)
If node.HasChildNodes Then
output &= String.Format("<ul>{0}</ul>", _
GetSiteMapLevelAsBulletedList(node.ChildNodes))
End If
output &= "</li>"
Next
Return output
End Function
Skulle gerne skrive et sitemap ud.