C
carlos
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;
}
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;
}