We help IT Professionals succeed at work.

asp.net -- site map - dynamic?

Tom Knowlton
Tom Knowlton asked
on
If I go:

Project - Add New Item and then add a SiteMap template ---  can this template be edited at runtime and the navigational links will refresh?

Or, must all of the navigational links be setup in advance, only?
Comment
Watch Question

Tom KnowltonWeb developer

Author

Commented:
I want to use the original Web.sitemap file - and just add to it.  The ideal would be able to add, modify and delete nodes in the sitemap at runtime, but if I could just add to the sitemap that would be a start.

I do not want to use a database or provider.  I just want to modify the xml file named "Web.sitemap"

If there is code that does this I'd like that.


None of the links you gave seemed to be what I wanted.
GlobaLevelProgrammer

Commented:
The bolew sample can remove some items form the menu control on the page, but the sitemap file can not be changed:

 protected void Menu1_MenuItemDataBound(object sender, MenuEventArgs e)
    {
        System.Web.UI.WebControls.Menu menu = (System.Web.UI.WebControls.Menu)sender;
        SiteMapNode mapNode = (SiteMapNode)e.Item.DataItem;

        System.Web.UI.WebControls.MenuItem itemToRemove = menu.FindItem(mapNode.Title);

        if (mapNode.Title == "Node")
        {
            System.Web.UI.WebControls.MenuItem parent = e.Item.Parent;
            if (parent != null)
            {
                parent.ChildItems.Remove(e.Item);
            }
        }
    }

Tom KnowltonWeb developer

Author

Commented:
>>>the sitemap file can not be changed:

Why not?

Are there any workarounds?

Are there alternatives that DO allow you to modify the sitemap at runtime?
Programmer
Commented:
Are there any workarounds?

>>> yes...do it all in an aspx page and SQL DB....
Tom KnowltonWeb developer

Author

Commented:
>>>>>>yes...do it all in an aspx page and SQL DB....

I was afraid you were going to say that.....  :(
Tom KnowltonWeb developer

Author

Commented:
Are there any "crawler" utilities that can SCAN your website structure and generate a Web.sitemap file for you?

I think I could even write one...but I'd rather leverage the efforts of other people if I can.

This would help save me time.
Tom KnowltonWeb developer

Author

Commented:
thx