467,877 Members | 1,219 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,877 developers. It's quick & easy.

How do I use a treeview with a sitemap file from another web site?

Hello,

I want to show a treeview display of the contents of a sitemap file on
another web site, chosen according to the currently logged on user. I
know at run time the path to the sitemap file, but this cannot be
determined at design time as it depends who logs in.

Can I do this? I can't see how without writing my own provider, which
seems like a lot of work for such a simple request?

TIA

--
Alan Silver
(anything added below this line is nothing to do with me)
Dec 19 '05 #1
  • viewed: 1464
Share:
6 Replies
use:

System.Net.WebClient wc = new System.Net.WebClient();
byte[] response = wc.UploadData("http://address.com/settingsFile?user=" +
userId, "GET", null);

string strResponse = System.Text.Encoding.ASCII.GetString(response);
Dec 19 '05 #2
Thanks for the reply. Sorry, I wasn't clear what I meant.

I have full access to the server, and both web sites are on the same
server, so accessing the sitemap file itself is just a case of getting
the right path, which is easy.

My question was more how to load a sitemap file that isn't called
"web.sitemap" in the current web site. The SiteMapDataSource doesn't
seem to have an option for specifying the sitemap file to use, it just
assumes that you want to use the current site's "web.sitemap." I would
like to know if there is a way of loading a different sitemap file (even
another one in the same web site for that matter) so it can be used.

Thanks for the reply. Any further help appreciated.
use:

System.Net.WebClient wc = new System.Net.WebClient();
byte[] response = wc.UploadData("http://address.com/settingsFile?user=" +
userId, "GET", null);

string strResponse = System.Text.Encoding.ASCII.GetString(response);


--
Alan Silver
(anything added below this line is nothing to do with me)
Dec 20 '05 #3
>Does this help
http://msdn2.microsoft.com/library/ms178426.aspx


Partly, and partly not. Is it possible to specify the file in at
run-time? The situation is that I have an admin site that is used by
people who use my e-commerce package. There is one admin site, and this
is used by everyone. They log in, and the user name is used to identify
the path to the root directory of their web site. I want to use that
path to load up their web.sitemap file.

I don't really want to add the sitemap files to the web.config file as
this means duplicating information, which is bound to cause problems. At
the moment, there is one config file per site, living in the App_Data
folder of the site. The admin site knows the path to each site, so it
can just pick up the config file, and anything else it wants from the
user site.

What I would really like is some way of telling the SiteMapDataSource
(or similar) at run-time which sitemap file to load. This seems to
simple and obvious, but I can't see how to do it.

Any further suggestions appreciated. Thanks again.

--
Alan Silver
(anything added below this line is nothing to do with me)
Dec 20 '05 #5
You might have to create a customer SiteMapProvider, and if you go through
all that trouble you might want to think about incorporating it into your
database, since the siteMap will be based on the user.

http://msdn2.microsoft.com/library/s...pprovider.aspx
Look at the LoadSiteMapFromStore function

Dec 20 '05 #6
>You might have to create a customer SiteMapProvider, and if you go through
all that trouble you might want to think about incorporating it into your
database, since the siteMap will be based on the user.

http://msdn2.microsoft.com/library/s...pprovider.aspx
Look at the LoadSiteMapFromStore function


Thanks for that.

It occurred to me that maybe I'm thinking about this the wrong way. The
web.sitemap file is just an XML file, so maybe I should just declare an
XmlDataSource and set the DataFile property to the web.sitemap file. I
can then use the XmlDataSource as the data source for the tree view.

This turned out to be very easy!! Sample code is shown below...

<asp:TreeView id="BookTreeView" DataSourceID="BookXmlDataSource"
runat="server">
<DataBindings>
<asp:TreeNodeBinding DataMember="siteMapNode" TextField="Title"/>
</DataBindings>
</asp:TreeView>

<asp:XmlDataSource id="BookXmlDataSource"
DataFile="D:\WebSites\TestSite\web.sitemap" runat="server" />

This has the path to the file hard-coded for testing. In the real code,
I would just do that bit at run-time.

All I have to do now is work out how to control the treeview. I would
like to start the treeview displaying at the first SiteMapNode, ignoring
the SiteMap node that is at the root of the sitemap file. Any ideas
about this?

Thanks

--
Alan Silver
(anything added below this line is nothing to do with me)
Dec 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Andy Sutorius via DotNetMonster.com | last post: by
5 posts views Thread by Tim Mackey | last post: by
1 post views Thread by Robert Dufour | last post: by
4 posts views Thread by =?Utf-8?B?R2VyaGFyZA==?= | last post: by
reply views Thread by jack112 | last post: by
reply views Thread by MrMoon | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.