Building Menus Dynamically

Last post 09-16-2004 6:23 PM by yaip. 6 replies.

Sort Posts:

  • Building Menus Dynamically

    08-31-2004, 12:03 PM
    • Contributor
      4,773 point Contributor
    • yaip
    • Member since 10-27-2003, 10:29 AM
    • Los Angeles, CA
    • Posts 1,145
    I want to use the SiteMapDataSource object with providing my own SiteMapProvider. This SiteMapProvider could be my SQL Server database where my Menu tables will be stored. Here is what I would want to do.

    - Read the SQL Server database
    - Populate the file (?) which is required by SiteMapDataSource
    - Use SiteMapDataSource to build my menu
    Thanks
    I love computers because: MY WISH IS THEIR COMMAND :)

    <Website>
    <Gadget>
  • Re: Building Menus Dynamically

    08-31-2004, 12:27 PM
    • All-Star
      29,644 point All-Star
    • Fredrik N
    • Member since 06-22-2002, 5:03 AM
    • Sweden
    • Posts 5,334
    To build your own SiteMapProvider for the SiteMapDataSOurce control, you have to create a class that inherits the SiteMapProvider and implements the functiannality to get nodes etc from a Sql server.
    /Fredrik Normén - fredrikn @ twitter

    ASPInsider

    Microsoft MVP, MCSD, MCAD, MCT

    ASPInsiders
    My Blog
  • Re: Building Menus Dynamically

    08-31-2004, 1:16 PM
    • Contributor
      4,773 point Contributor
    • yaip
    • Member since 10-27-2003, 10:29 AM
    • Los Angeles, CA
    • Posts 1,145
    In MSDN help, they are showing an example on how to do that with a text file. But it is just a source code. It doesn't tell you how and where to plug it in. Where to pass the values, etc.
    Thanks
    I love computers because: MY WISH IS THEIR COMMAND :)

    <Website>
    <Gadget>
  • Re: Building Menus Dynamically

    09-01-2004, 12:44 PM
    • Contributor
      4,773 point Contributor
    • yaip
    • Member since 10-27-2003, 10:29 AM
    • Los Angeles, CA
    • Posts 1,145
    I've got the SiteMapDataSource working correctly where it fetches data from my SQL Server database. However, my SiteMapPath is not showing at all. This is a very important feature. I thought that since my SiteMapDataSource is updated correctly, my SiteMapPath would automatically be reflecting the changes. Do I need to do something for my SiteMapPath to show. If yes, where?
    Thanks
    I love computers because: MY WISH IS THEIR COMMAND :)

    <Website>
    <Gadget>
  • Re: Building Menus Dynamically

    09-14-2004, 4:57 AM
    • All-Star
      17,195 point All-Star
    • Dave Sussman
    • Member since 06-17-2002, 11:53 AM
    • UK
    • Posts 2,376
    • TrustedFriends-MVPs
    Are you saying you've written a DataSource control that fetches data directly from the database? If so that's the reason the SiteMapPath isn't working, as it hooks into the site map provider, not the data source control. You can see this by the fact that you don't need a SiteMapDataSource control to use the SiteMapPath.

    What you need to do is write a provider. Once written (the text provider in the docs is a good base), you can plug it it by adding the provider to the <providers> element of the <siteMap> section in web.config:

    <siteMap enabled="true">
    <providers>
    <add name="myProvider" description"..." type="namespace.class"
    [provider-specific-properties] />
    </providers>
    </siteMap>

    You can then use this in your pages:

    <asp:SiteMapDataSource Provider="myProvider" ... />

    <asp:SiteMapPath Provider="myProvider" ... />

    Dave
  • Re: Building Menus Dynamically

    09-16-2004, 5:17 PM
    • Member
      45 point Member
    • ezeckiel
    • Member since 07-30-2004, 6:44 AM
    • Posts 9
    Hello,

    I need to write a class extends SiteMapProvider class too, but I'm a newbie in C# and I don't know how to write it :'(. I would like to populate the SiteMapDataSource with a Sqlserver Table.

    somebody could write a short example please ?

    Thanks very well !
  • Re: Building Menus Dynamically

    09-16-2004, 6:21 PM
    • Contributor
      4,773 point Contributor
    • yaip
    • Member since 10-27-2003, 10:29 AM
    • Los Angeles, CA
    • Posts 1,145
    I also want to do the same but was not getting a good example. Unlike you, I'd like it in vb. Could you please post your example if you get it. I'll do the same. I guess these are the perils of living on a bleeding-edge. Lack of good documentation. But I am sure MS will sort this out when they go GA.
    Thanks
    I love computers because: MY WISH IS THEIR COMMAND :)

    <Website>
    <Gadget>
Page 1 of 1 (7 items)