Esempio n. 1
0
        protected void Button1_Click1(object sender, EventArgs e)
        {
            //List<UserData> LstUserData = new List<UserData>();//it overwrite data
            List <EmpInfo> LstEmpData = Session["User"] != null ? (List <EmpInfo>)Session["User"] : new List <EmpInfo>();
            EmpInfo        emp        = LstEmpData.Find(x => x.userName == txtEmpName.Text);

            if (emp == null)
            {
                emp          = new EmpInfo();
                emp.userName = txtEmpName.Text;
                emp.mailid   = txtemail.Text;
                emp.phone    = txtboxPhone.Text;
                //emp.state = state.Text;
                //emp.city = dropdwn.Text;

                emp.userName = txtEmpName.Text;
                emp.password = txtpass.Text;

                LstEmpData.Add(emp);
                Session["User"] = LstEmpData;
                Label3.Text     = "User Registered Successfully";

                //GridView1.DataSource = LstEmpData;
                //GridView1.DataBind();
                Response.Redirect("~/loginForm.aspx?empname=" + txtEmpName.Text);
            }
            else if (emp != null)
            {
                //Labelmsg.Text = "User Is already Registered!";
                Response.Redirect("~/loginForm.aspx");
            }
        }
Esempio n. 2
0
        protected void Button1_Click1(object sender, EventArgs e)
        {
            if (Request.QueryString["empname"] != null)
            {
                // List<EmpInfo> LstEmpData = new List<EmpInfo>();
                List <EmpInfo> LstEmpData = Session["User"] != null ? (List <EmpInfo>)Session["User"] : new List <EmpInfo>();
                EmpInfo        emp        = LstEmpData.Find(x => x.userName == Request.QueryString["empname"]);
                if (emp != null)
                {
                    //label1.Text = "User Is already Registered!";
                    txtUserName.Text     = emp.userName;
                    txtUserPassword.Text = emp.userName;
                }

                gd.DataSource = LstEmpData;
                gd.DataBind();
            }


            //if (FormsAuthentication.Authenticate(txtUserName.Text, txtUserPassword.Text))
            //{
            //    FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, true);
            //}
            //else
            //{
            //    errLabel.Text = "Invalid User Name AND/OR Password";
            //}
            //GridView2.DataSource = LstEmpData;
            //GridView2.DataBind();
        }