Reputation: 2313
I have a form called frmLogin. I have code within the Login_1Authenticate event handler that checks the security level of the username and password entered. Then depending on the security level it will display or not display links on my main form called frmMain. If it is security level “A” I want full control, but if it security level “U” then I want link buttons and image buttons removed from frmMain. An example of two of them to disable are:
linkbtnEmployee
imgbtnNewEmployee
linkbtnViewUserActivity
imgbtnViewUserActivity
I need to write the code for the Page_Load event, but I’m not sure how to write it. Here’s the code for my frmLogin page:
public partial class frmLogin : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{
dsUser dsUserLogin;
string SecurityLevel;
dsUserLogin = clsDataLayer.VerifyUser(Server.MapPath("PayrollSystem_DB.mdb"),
Login1.UserName, Login1.Password);
if (dsUserLogin.tblUserLogin.Count < 1)
{
e.Authenticated = false;
return;
}
SecurityLevel = dsUserLogin.tblUserLogin[0].SecurityLevel.ToString();
switch (SecurityLevel)
{
case "A":
// Add your comments here
e.Authenticated = true;
Session["SecurityLevel"] = "A";
break;
case "U":
// Add your comments here
e.Authenticated = true;
Session["SecurityLevel"] = "U";
break;
default:
e.Authenticated = false;
break;
}
}
}
Upvotes: 3
Views: 787
Reputation: 305
Please read http://msdn.microsoft.com/en-us/library/ff647070.aspx
to understand "Forms Authentication in ASP.NET 2.0"
Upvotes: 0
Reputation: 62439
Well if you want them to be invisible use:
linkbtnEmployee.Visible = false;
imgbtnNewEmployee.Visible = false;
Upvotes: 2