Is anyone know how to populating the menu by user role using SiteMapDataSource in vb code?I found a lot of code use the c#. Im not familiar with that.
Anyone can help me to convert this "VB" code will be more appreciate.
Calvin
C#:
"Login Page" <-this is simple login authentication page
protected void Button1_Click(object sender, EventArgs e)
{
string userName = txtUserName.Text;
if (userName.Equals("admin"))
Response.Redirect("~/Admin/AdminHomePage.aspx");
else if (userName.Equals("user"))
Response.Redirect("~/User/UserHomePage.aspx");
}
"Class File - Navigation Manager"
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public class NavigationManager
{
public static SiteMapDataSource GetSiteMapDataSource(string role) { <--How to change to VB code???
string url = String.Empty;
if (role.Equals("Admin")) <--- Question 1: How it get this role??, since txtUserName.Text is store in userName
url = "~/AdminAdminHomePage.aspx";
else if (role.Equals("User"))
url = "~/User/UserHomePage.aspx";
XmlSiteMapProvider xmlSiteMap = new XmlSiteMapProvider();
System.Collections.Specialized.NameValueCollection myCollection = new System.Collections.Specialized.NameValueCollection(1);
myCollection.Add("siteMapFile", "Web.sitemap");
xmlSiteMap.Initialize("provider", myCollection);
xmlSiteMap.BuildSiteMap();
SiteMapDataSource siteMap = new SiteMapDataSource();
siteMap.StartingNodeUrl = url;
siteMap.ShowStartingNode = false;
return siteMap;
}
}
Calvin
Last edited by a moderator: