I have an asp.net website with different user types like admin, registered user. Each user type has different menu options.
I have created a common master page for all types of users, but designed different sitemap files for different user types.
What I am trying to do is, after login according to the user type the sitemap should change in Master Page.
Here is the code I tried in master page loading. It is showing me error like
**The SiteMapProvider 'Principal.sitemap' cannot be found.**
I tried with and without .sitemap extension. (I have principal.sitemap and other sitemaps)
protected void Page_Load(object sender, EventArgs e)
{
if (Session["usertype"] == null)
{
Response.Redirect("loginpage.aspx");
return;
}
String usertype = Session["usertype"].ToString();
if (usertype == "Principal")
{
SiteMapDataSource1.SiteMapProvider = "Principal.sitemap";
}
else if (usertype == "Administrator")
{
//SiteMapDataSource1.SiteMapProvider = "Administrator";
}
else if (usertype == "Student")
{
SiteMapDataSource1.SiteMapProvider = "Student";
}
foo.DataBind();
}
Here is my Master Page aspx code part.
<asp:SiteMapDataSource ID="SiteMapDataSource1" ShowStartingNode="false" runat="server" />
<ul id="cssmenu1">
<li><a id="A1" href="index.aspx" runat="server">Home</a></li>
<asp:Repeater ID="foo" DataSourceID="SiteMapDataSource1" EnableViewState="false"
runat="server" onitemcommand="foo_ItemCommand">
<ItemTemplate>
<li>
<a href='<%#Eval("url") %>'><%#Eval("Title") %></a>
<ul>
<asp:Repeater ID="bar" DataSource='<%# ((SiteMapNode) Container.DataItem).ChildNodes %>' runat="server">
<ItemTemplate>
<li><a href='<%#Eval("url") %>'><%#Eval("Title") %></a></li>
</ItemTemplate>
</asp:Repeater>
</ul>
</li>
</ItemTemplate>
</asp:Repeater>
</ul>
</div>