Hi ,
I have deon the login page with the 3 level of security, 1 User, 2 Manager,3 Admin. For Admin and Manager am keeping same screen(Default.aspx), But for User i want to maintain the another page(Default1.aspx). Here i have attached the Source code for Login page, But it is working only for Admin and Manager only , it means it is opening only Default.aspx page . For user also it is opening same page. can any one please tell me how to open the another page(Default1.aspx) for user login. I have attached my code in this forum.
Am waiting for your mail.
This is the code:
namespace
QFD
{
//
// Filename: Login.cs
//-------------------------------
//
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
/// <summary>
/// Summary description for Login.
/// </summary>
public partial class Login : System.Web.UI.Page
{
//Login CustomIncludes begin
protected CCUtility Utility;
//Login form Login variables and controls declarations
protected System.Web.UI.HtmlControls.HtmlInputHidden Login_querystring;
protected System.Web.UI.HtmlControls.HtmlInputHidden Login_ret_page;
// For each Login form hiddens for PK's,List of Values and Actions
protected string Login_FormAction="Default.aspx?";
protected string Login_FormAction1 = "Default1.aspx?";
public Login()
{
this.Init += new System.EventHandler(Page_Init);
}
// Login CustomIncludes end
//-------------------------------
public void ValidateNumeric(object source, ServerValidateEventArgs args) {
try{
Decimal temp=Decimal.Parse(args.Value);
args.IsValid=
true;
}
catch{
args.IsValid=
false; }
}
//===============================
// Login Show begin
protected void Page_Load(object sender, EventArgs e)
{
Utility=
new CCUtility(this);
//===============================
// Login Open Event begin
// Login Open Event end
//===============================
//===============================
// Login OpenAnyPage Event begin
// Login OpenAnyPage Event end
//===============================
//
//===============================
// Login PageSecurity begin
// Login PageSecurity end
//===============================
if (Session["UserID"] != null && Int16.Parse(Session["UserID"].ToString()) > 0)
Login_logged =
true;
if (!IsPostBack){
Page_Show(sender, e);
}
}
protected void Page_Unload(object sender, EventArgs e)
{
//
// CODEGEN: This call is required by the ASP+ Windows Form Designer.
//
if(Utility!=null) Utility.DBClose();
}
protected void Page_Init(object sender, EventArgs e)
{
//
// CODEGEN: This call is required by the ASP+ Windows Form Designer.
//
InitializeComponent();
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
}
protected void Page_Show(object sender, EventArgs e)
{
Login_Show();
}
// Login Show end
/*===============================
Display Login Form
-------------------------------*/
protected
bool Login_logged = false;
void
Login_Show() {
// Login Show begin
// Login Open Event begin
// Login Open Event end
// Login BeforeShow Event begin
// Login BeforeShow Event end
if (Login_logged) {
// User logged in
Login_login.Text =
"Logout";
Login_trpassword.Visible =
false;
Login_trname.Visible =
false;
Login_labelname.Visible =
true;
Login_labelname.Text = Utility.Dlookup(
"users", "login", "user_id=" + Session["UserID"]) + " ";
}
else {
// User is not logged in
Login_login.Text =
"Login";
Login_trpassword.Visible =
true;
Login_trname.Visible =
true;
Login_labelname.Visible =
false;
}
// Login Close Event begin
// Login Close Event end
// Login Show end
}
protected
void Login_login_Click(Object Src, EventArgs E) {
if (Login_logged) {
// Login Logout begin
// Login OnLogout Event begin
// Login OnLogout Event end
Login_logged =
false;
Session[
"UserID"] = 0;
Session[
"UserRights"] = 0;
Login_Show();
// Login Logout end
}
else {
// Login Login begin
int iPassed = Convert.ToInt32(Utility.Dlookup("users", "count(*)", "login ='" + Login_name.Text + "' and pass='" + CCUtility.Quote(Login_password.Text) + "'"));
if (iPassed > 0) {
// Login OnLogin Event begin
// Login OnLogin Event end
Login_message.Visible =
false;
Session[
"UserID"] = Convert.ToInt32(Utility.Dlookup("users", "user_id", "login ='" + Login_name.Text + "' and pass='" + CCUtility.Quote(Login_password.Text) +"'"));
Login_logged =
true;
Session[
"UserRights"] = Convert.ToInt32(Utility.Dlookup("users", "security_level", "login ='" + Login_name.Text + "' and pass='" + CCUtility.Quote(Login_password.Text) + "'"));
string sQueryString = Utility.GetParam("querystring");
string sPage = Utility.GetParam("ret_page");
if (! sPage.Equals(Request.ServerVariables["SCRIPT_NAME"]) && sPage.Length > 0) {
Response.Redirect(sPage +
"?" + sQueryString);
}
else {
Response.Redirect(Login_FormAction);
}
}
else {
Login_message.Visible =
true;
}
// Login Login end
}
}
// End of Login form
}
}