473,414 Members | 1,675 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

dynamic sitemap binding.

I am using asp.net 2.0 to bind my menu controls using xml
web.sitemaps. I created a sitemap for each role, and what I am trying
to do is dynamically bind the menucontrol's datasource with the
appropriate sitemap based on the logged in user's role. It is not
working though. Any ideas?

//Master Page Code Behind
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{

//Load SiteMap
MyMenu.DataSource =
GetMenuDataSource(Server.MapPath("~"));
MyMenu.DataBind();
}
}

private XmlDataSource GetMenuDataSource(string serverMapPath)
{
XmlDataSource objData = new XmlDataSource();
objData.XPath = "siteMap/siteMapNode";

if (Roles.IsUserInRole("Admin"))
{
objData.DataFile = serverMapPath + @"\App_Data
\admin.sitemap";
}
else if (Roles.IsUserInRole("Public"))
{
objData.DataFile = serverMapPath + @"\App_Data
\public.sitemap";
}
else if (Roles.IsUserInRole("Private"))
{
objData.DataFile = serverMapPath + @"\App_Data
\private.sitemap";
}

objData.DataBind();
return objData;
}
Jul 10 '08 #1
1 2619
On 10 Jul, 21:32, carlos <ubuntu4car...@yahoo.comwrote:
I am using asp.net 2.0 to bind my menu controls using xml
web.sitemaps. I created a sitemap for each role, and what I am trying
to do is dynamically bind the menucontrol's datasource with the
appropriate sitemap based on the logged in user's role. It is not
working though. Any ideas?

//Master Page Code Behind
*protected void Page_Load(object sender, EventArgs e)
* * * * {
* * * * * * if (!IsPostBack)
* * * * * * {

* * * * * * * * //Load SiteMap
* * * * * * * * MyMenu.DataSource =
GetMenuDataSource(Server.MapPath("~"));
* * * * * * * * MyMenu.DataBind();
* * * * * * }

* * * * }

*private XmlDataSource GetMenuDataSource(string serverMapPath)
* * * * {
* * * * * * XmlDataSource objData = new XmlDataSource();
* * * * * * objData.XPath = "siteMap/siteMapNode";

* * * * * * if (Roles.IsUserInRole("Admin"))
* * * * * * {
* * * * * * * * objData.DataFile = serverMapPath + @"\App_Data
\admin.sitemap";
* * * * * * }
* * * * * * else if (Roles.IsUserInRole("Public"))
* * * * * * {
* * * * * * * * objData.DataFile = serverMapPath + @"\App_Data
\public.sitemap";
* * * * * * }
* * * * * * else if (Roles.IsUserInRole("Private"))
* * * * * * {
* * * * * * * * objData.DataFile = serverMapPath + @"\App_Data
\private.sitemap";
* * * * * * }

* * * * * * objData.DataBind();
* * * * * * return objData;
* * * * }
No need to do it that way. Use a single Sitemap file and for each of
the restricted nodes add an attribute roles="..."
Jul 10 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: festiv | last post by:
Hi there, I want to learn how the compiler is implementing the dynamic binding. where can i read about this subject (the hole process). thanks.
4
by: Robert Camsky | last post by:
Hi, I've got web.sitemap file with few nodes and subnodes and SiteMapPath control. It works fine. But imagine, I'm worrking on an calender implemented this way: calendar.aspx -> showing...
1
by: Danial | last post by:
Hi, How can I bind sitemappath (breadcrumb control of asp.net) to a custom ..sitemap file? By defualt its looking for web.sitemap file and giving me not found exception. Thanks Danial
3
by: Ray Booysen | last post by:
Hi all I have a treeview bound to a sitemap. Once the user is logged in, I'm wanting the menu to expand to include additional items from a database while retaining the items in the sitemap. Is...
1
by: Luca88 | last post by:
Easy to use, install and configure, this is a php script that allows the generating of the sitemap.xml (xml sitemap requested by “Google Sitemap System”) in real time. Together with a custom...
6
by: rlueneberg | last post by:
Can someone tell if Sitemap always require a starting root? Can it have more than one root? I am having a problem trying to hide a root node without hiding its children using a Treeview component....
3
by: Smokey Grindel | last post by:
I'm making some custom controls that make use of the current site map, I need to know what node the current page that is loaded is on in the site map though, how do you get this information out of...
1
by: jesibl | last post by:
Hi All, I have an ASP .NET 2.0 web based app which should change content based on a variable passed in the query string. Let's say the variable is called ID and the variations are A, B and C. ...
2
by: =?Utf-8?B?SmFtZXMgUGFnZQ==?= | last post by:
I’m trying to create a dynamic asp.net 2.0 siteMapPath control (using VB.net). Using the xml sitemap I’ve got these three pages: productGroup.aspx productListing.aspx productDetail.aspx ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.