2014年7月13日 星期日

[RESOLVED] User Login????


i have four pages asp.net (c#)


(1) Login Page (2) MainMenu1   (3) MainMenu2 (4) MainMenu3


i also have sql database name "mydatabase" have three tables 


(1) Student (2) Teacher   (3) Admin


Login page contain 2 textboxes (  textbox1 for username,  textbox2 for password) and login button


i want when login button is pressed then check (match) username and password in three tables (Student ,Teacher ,Admin)


*if user is Student then page MainMenu1 is open


*if user is Teacher then page MainMenu2 is open


*if user is Admin then page MainMenu3 is open


plzzzzzz help me?????



Ok, post your code.  I think it would be nothing more than code behind visibility statements based on


if (!User.IsInRole == "Student") 
{
Menu1.Visibility = hidden;
}
else
{
Menu1.Visibility = visible;
}



At what stage are you?  Are you in the process of setting up the databases / tables? Or are you having to work with pre-existing tables?


Because if you are just starting, then the suggestion of bbcompent1 is a slick way to do it.  When each user is created, you would want a bit of code-behind to assign that user to one of the three Roles.


Then you probably only only need the tables that come with the asp.net membership, no need to add separate tables for the students, teachers, and admin.


And you only need one page for the menus -- not three -- just showing or hiding them as suggested.


沒有留言:

張貼留言