Hi I Want To Retain The Value Of A Text Box Which Is In Password Mode. Pls Send Me I Already Use Cookie, Hidden Variable . Its Not Working
Do like this your problem is solved
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DataAccessLayer;
public partial class loginform : System.Web.UI.Page
{
DataLayer dl = new DataLayer();
DataSet ds = new DataSet();
protected void Page_Load(object sender, EventArgs e)
{
lblerrormesg.Visible = false;
if (Request.Cookies["myCookie"] != null)
{
chkPersistLogin.Checked = true;
HttpCookie cookie = Request.Cookies.Get("myCookie");
txtemail.Text = cookie.Values["Email"].ToString();
string pass = cookie.Values["Pass"].ToString();
txtpassword.Attributes.Add("value", pass);
}
if (chkPersistLogin.Checked)
{
HttpCookie myCookie = new HttpCookie("myCookie");
//Response.Cookies.Remove("myCookie");
Response.Cookies.Add(myCookie);
myCookie.Values.Add("Email", txtemail.Text.ToString());
myCookie.Values.Add("Pass", txtpassword.Text.ToString());
DateTime dtExpiry = DateTime.Now.AddMinutes(15); //you can add years and months too here
Response.Cookies["myCookie"].Expires = dtExpiry;
}
}
protected void butnrealestlogin_Click(object sender, EventArgs e)
{
//CheckBox rm = (CheckBox)Login1.FindControl("chkPersistLogin");
string Email = txtemail.Text.ToString();
string Password = txtpassword.Text.ToString();
ds = dl.Login(Email, Password);
int i =ds.Tables["UserDetails"].Rows.Count;
if (i==1)
{
Session["Email"] = Email;
Session["UserName"] = ds.Tables[0].Rows[0][3].ToString();
Session["Phone"]=Convert.ToInt32(ds.Tables[0].Rows[0][4].ToString());
if (Request.Cookies["myCookie"] != null)
{
HttpCookie cookie = Request.Cookies.Get("myCookie");
string emailID = cookie.Values["Email"].ToString();
string password = cookie.Values["Pass"].ToString();
string pass = cookie.Values["Pass"].ToString();
txtpassword.Attributes.Add("value", pass);
}
int j=0;
string str=Request.QueryString["id"];
if (str!="ForumForm.aspx")
j=Convert.ToInt32(str);
if (j != 0)
Response.Redirect("PostReply.aspx?id=" + j);
if (str == "ForumForm.aspx")
Response.Redirect("ForumForm.aspx?parentform=login ");
string parentform = Request.QueryString["parentform"];
if (parentform == "PostyourQuestion")
Response.Redirect("PostyourQuestion.aspx");
if (parentform == "emailtoagent")
Response.Redirect("EmailtoAgent.aspx?&parentform=c heckbox");
if (parentform == "userprofile")
Response.Redirect("UserProfile.aspx");
else if(i==0)
{
Response.Write("Something went wrong... please re-enter your credentials...");
}
//string str1 = "<script language=javascript>";
//Response.Write("hi");
//str1 += "Self.close('FrentPage.aspx');";
//str1 += "</script>";
//Response.Write(str1);
Response.Write("Your Successfully LogedIn");
}
else if(i==0)
{
lblerrormesg.Visible = true;
lblerrormesg.Text = "Wrong EmailID or Password" + '\n' + '\n' + "Have your Register as Member?";
//Response.Redirect("Message.aspx?Id=1");
}
}
protected void lnkbutnclickhere_Click(object sender, EventArgs e)
{
Response.Redirect("Forgetpassword.aspx");
}
protected void lnkbutnsuggestion_Click(object sender, EventArgs e)
{
Response.Redirect("ContactUs.aspx");
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
Response.Redirect("UserRegistration.aspx");
}
}