hello ,
I am following this link
i can use the login for 2 Table users ?
i have Table_infoname with 170 users and i have Table_users with 10 users
can i make them same login page or i need make 2 x login with radio list or dropdownlist
<asp:Login ID = "Login1" runat = "server" OnAuthenticate= "ValidateUser" BackColor="#E4E4E4" BorderStyle="Solid" BorderWidth="2px" Font-Names="Arial" Font-Size="Large" Height="257px" Width="450px" CssClass="auto-style7" Font-Bold="True" LoginButtonText="دخول" PasswordLabelText="كلمة المرور:" TitleText="تسجيل الدخول" UserNameLabelText="الرقم المدني:" RememberMeText="login" FailureText="تأكد من الرقم المدنى / كلمة المرور" DisplayRememberMe="False">
<LoginButtonStyle BackColor="#0E5297" Font-Bold="True" Font-Names="Arial" Font-Size="X-Large" Width="100%" ForeColor="White" />
<TextBoxStyle Height="20px" Width="300px" />
<TitleTextStyle BackColor="#2070A6" Font-Bold="True" ForeColor="#FFFFFF" />
</asp:Login>
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Page.User.Identity.IsAuthenticated)
{
FormsAuthentication.SignOut();
Response.Redirect("~/Login.aspx");
}
}
}
protected void ValidateUser(object sender, EventArgs e)
{
readdataname();
string IpassAstringfrompage1 = Convert.ToString(Session["Name"]);
int Id = 0;
string roles = string.Empty;
string constr = ConfigurationManager.ConnectionStrings["kankonConnectionString"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("Validate_User"))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@civilid", Login1.UserName);
cmd.Parameters.AddWithValue("@Password", Login1.Password);
cmd.Connection = con;
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
reader.Read();
Id = Convert.ToInt32(reader["Id"]);
roles = reader["Roles"].ToString();
con.Close();
}
switch (Id)
{
case -1:
Login1.FailureText = "Username and/or password is incorrect.";
break;
case -2:
Login1.FailureText = "Account has not been activated.";
break;
default:
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, IpassAstringfrompage1, DateTime.Now, DateTime.Now.AddMinutes(2880), Login1.RememberMeSet, roles, FormsAuthentication.FormsCookiePath);
string hash = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, hash);
if (ticket.IsPersistent)
{
cookie.Expires = ticket.Expiration;
}
Response.Cookies.Add(cookie);
Response.Redirect(FormsAuthentication.GetRedirectUrl(IpassAstringfrompage1, Login1.RememberMeSet));
break;
}
}
}