protected void btnLogin_Click(object sender, EventArgs e) { SBObj _sbobj = new SBObj(); Session["errMSG"] = ""; Session["lanid"] = txtUserName.Text; if (txtUserName.Text == "") { Session["errMSG"] = "Invalid EID"; malingmensahe.ForeColor = System.Drawing.Color.Red; malingmensahe.Text = "Invalid EID"; } else { try { if (Session["errMSG"].ToString().Equals(string.Empty)) { DataTable dt = new DataTable(); dt = _sbobj.getLoginDetails((string)Session["lanid"]).Tables[0]; if (dt.Rows.Count == 0) { Session["errMSG"] = "Something Went Wrong"; Response.Redirect("~/Login.aspx"); Response.Cookies["lanid"].Expires = DateTime.Now.AddHours(-1); Response.Cookies["Type"].Expires = DateTime.Now.AddHours(-1); } else { DataSet ds = new DataSet(); ds = _sbobj.getLoginDetails((string)Session["lanid"]); foreach (DataRow drow in ds.Tables[0].Rows) { Session["Type"] = drow["Type"].ToString(); Session["lanid"] = drow["EID"].ToString(); Response.Redirect("~/Default.aspx"); Response.Cookies["lanid"].Expires = DateTime.Now.AddHours(1); Response.Cookies["Type"].Expires = DateTime.Now.AddHours(1); //Response.Cookies["lanid"].Value = txtUserName.Text.Trim(); } } } else { } } catch (Exception) { malingmensahe.ForeColor = System.Drawing.Color.Red; malingmensahe.Text = "You are not yet Registered"; Response.Cookies["lanid"].Expires = DateTime.Now.AddHours(-1); Response.Cookies["Type"].Expires = DateTime.Now.AddHours(-1); //Response.Redirect("~/Login.aspx"); //malingmensahe.ForeColor = System.Drawing.Color.Red; //malingmensahe.Text = "Invalid EID"; //throw; } } }