CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 10/1/2006 12:16:03 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 1 Views: 32 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
2 Items, 1 Pages 1 |< << Go >> >|
radishj
Asp.Net User
Need help on SiteMapProvider10/1/2006 12:16:03 PM

0/0

Hi,

I made a class DirSSMP that derived from StaticSiteMapProvider. It read out one of directories from E: drive and put those information in to the SiteMapProvider.

I created a .aspx web page with a TreeView and a SiteMapDataSource. In the PageLoad() of .aspx.cs file, I newed the DirSSMP and set it to the SiteMapDataSource.Provider.

When I run the page, it only show me the root node of the directory. When I checked step by step in debug, I did see that the RootNode was created and it got 21 childNodes.

Does anybody can help me out here? Thanks a lot. I'll copy some of my code under here.

 ----------------------------------------------------------------------------------------------

.aspx

<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default7.aspx.cs" Inherits="Default7" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
                    <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
                    <asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1">
                    </asp:TreeView>
</asp:Content>

-----------------------------------------------------------------------------------------------

.aspx.cs

public partial class Default7 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        DirSSMP photoDir = new DirSSMP();
        photoDir.Initialize("photoDir", null);
        SiteMapDataSource1.Provider = photoDir;
        TreeView1.ExpandAll();
    }
}
--------------------------------------------------------------------------------------------------

DirSSMP.cs

        public override void Initialize(string name, NameValueCollection attributes) {
            if (IsInitialized)
                return;

            base.Initialize(name, attributes);

             //Get directory information
            directory= new DirectoryInfo("E:\\newsite\\Photos");

            initialized = true;
        }

        ///
        /// SiteMapProvider and StaticSiteMapProvider methods that this derived class must override.
        ///
        // Clean up any collections or other state that an instance of this may hold.
        protected override void Clear() {
            lock (this) {
                rootNode = null;
                base.Clear();
            }
        }

        // Build an in-memory representation from persistent
        // storage, and return the root node of the site map.
        public override SiteMapNode BuildSiteMap() {

            // Since the SiteMap class is static, make sure that it is
            // not modified while the site map is built.
            lock(this) {

                // If there is no initialization, this method is being
                // called out of order.
                if (! IsInitialized) {
                    throw new Exception("BuildSiteMap called incorrectly.");
                }

                // If there is no root node, then there is no site map.
                if (null == rootNode) {
                    // Start with a clean slate
                    Clear();

                    int nodeID=0;
                    rootNode=new SiteMapNode(this, nodeID.ToString(),"E:\\newsite\\Photos","Photos");
                    makeDirTree(rootNode,ref nodeID);
                }
                return rootNode;
            }
        }

        private void makeDirTree(SiteMapNode parentNode,ref int nodeID)
        {
            string sURL,sName;
            int n;
            DirectoryInfo parentDir = new DirectoryInfo(parentNode.Url);
            SiteMapNode childNode;
            foreach (DirectoryInfo folder in parentDir.GetDirectories())
            {
                nodeID++;
                sURL = folder.FullName;
                n = sURL.LastIndexOf("\\");   //Get the dir or file name
                sName = sURL.Substring(n + 1);
                childNode=new SiteMapNode(this,nodeID.ToString(),sURL,sName);
                AddNode(childNode,parentNode);
                makeDirTree(childNode,ref nodeID);
            }
        }
   

radishj
Asp.Net User
Re: Need help on SiteMapProvider10/1/2006 6:42:05 PM

0/0

When I put in a Menu and set the dataSource to DirSSMP, the directory was showed correctly.

Weird, how come the treeview doesn't work?

HELP!!!

2 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Pro ASP.NET 3.5 in C# 2008 Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1498, Published: 2007
Pro ASP.NET 2.0 in VB 2005: special edition. Authors: Laurence Moroney, Matthew MacDonald, Pages: 1360, Published: 2006
ASP.NET 2.0: A Developer's Notebook Authors: Wei Meng Lee, Pages: 326, Published: 2005
Visual Basic 2005: A Developer's Notebook Authors: Matthew MacDonald, MacDonald Matthew, Pages: 243, Published: 2005
Beginning ASP.NET 2.0 in C# 2005: From Novice to Professional Authors: Matthew MacDonald, Pages: 1148, Published: 2006
Pro ASP.NET for SQL Server: High Performance Data Access for Web Developers Authors: Brennan Stehling, Pages: 408, Published: 2007
Pro ASP.NET 2.0 in C# 2005 Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1255, Published: 2005
Pro ASP.NET 2.0 in C# 2005: Create Next-generation Web Applications with the Latest Version of Microsoft's Revolutionary Technology Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1426, Published: 2006
Beginning ASP.NET 2.0 Authors: Chris Hart, John Kauffman, Chris Ullman, David Sussman, Pages: 759, Published: 2005
Beginning ASP.NET 2.0 with C# Authors: Chris Hart, John Kauffman, David Sussman, Chris Ullman, Pages: 735, Published: 2006

Web:
Need Help With SiteMapProvider - ASP.NET Forums NET » Master Pages, Themes and Navigation Controls » Need Help With SiteMapProvider ... Crying [:'(] Need Help With SiteMapProvider ...
Need Help With SiteMapProvider - ASP.NET Forums NET Forums » General ASP.NET » Master Pages, Themes and Navigation Controls » Need Help With SiteMapProvider ... Crying [:'(] Need Help With SiteMapProvider ...
Crafty Code - A Programming Blog My first version of the Google Sitemap Provider for DotNetNuke was developed off the ... If you need help faster than that, or can't figure out the answer, ...
microsoft.public.dotnet.framework.aspnet.security: Re: Serious ... Re: Serious help needed with beta 2.0 SiteMapProvider. .... its half a day job as you will have working UI and you just need to implement MySqlDataProvider, ...
Maarten Balliauw {blog} - Building an ASP.NET MVC sitemap provider ... NET MVC sitemap provider with security trimmingComments: 28Rating: 4 / 5; MSDN Chopsticks on ASP. ..... Serious help needed with beta 2.0 SiteMapProvider.. Talk about Serious help needed with beta 2.0 SiteMapProvider.. ... I need to prune the menu hierarchy based on user permissions. ...
MSDN SharePoint - Development and Programming how to create custom ... i have new scenario that i have two ASP Menus at my site, so i need to create custom SiteMapProvider. how to do that and how to make the new SiteMapProvider ...
TheMSsForum.com >> VB >> Custom providers (MembershipProvider ... I think i doing something wrong and need a bit help to continue her. I'm using VB 2005. Tag: Custom providers (MembershipProvider, SiteMapProvider, ...
Need Help...Problems With Site Working with GoDaddy.com - ng.asp ... macromedia.flash.actionscript3 - Web Programming ... need help with sitemapprovider. master page question. website ranksings with master pages ... need ...
MSDN SharePoint - Development and Programming SiteMapProvider ... Cache object and remove the one which you need to. this will referesh the cache. Hello all,. I've created a SiteMapProvider that read the items from a list ...




Search This Site:










changing attributes of master page from within content page

error:....database 'dotnetnuke' cannot be opened because it is version 611. this server supports version 607 and earlier.

login client automatically to any https website

multiple blogs and multiple domains

[help!] how do i redirect roles to customized pages using the login control?

dotnetnuke upgrade error

symmetric encryption key storage

themes vs css...

membership issue with portal id?

"cast from string "" to type 'date' is not valid" error

problems with web site administration tool

accessing form properties in a masterpage

how to protecte .net app?

custom role provider: object not set to an instance...

c# equivalent of addressof

script doesnot work when using a masterpage.

web form and authentication

how to fix the random photo performance problem ?

error installing dotnetnuke 2.1.2

how can i add some keywords in a aspx webpage?

design time appearance for the datagrid control

managing user information

what are the steps to create a search engine in our website

error: log viewer is currently unavailable. dnn 2.1.1

please help me

help! about access dotnetnuke sql db base on win 2003 server

formsauthentication cookie is not a session cookie (in 1.1 it was...)

using network resources with the domain, username, and password of the person logged in to the website.

how to call outside function from within custom membership provider

pulling my hair out with formsauth

 
All Times Are GMT