Hi guys i have a problem with my sign-out button , i have a button named"sign-out" appears when the user enter his username and password in the pop out form and the pop up form closed.
when the user enter his name and password the 2 boxes appears one contain(LABEL) (welcome and the username of the user ) and the other box(BUTTON) is the sign-out.
my problem is when i when i click the sign-out button i don't redirect to my page again to restart the cycle or delete any sessions or cookies.
here is the code.
code for the form sign in form:
<div class="user_login">
<form action="#">
<label>Email / Username</label>
<asp:TextBox ID="emailTextBox1" runat="server" MaxLength="20"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Please enter your Email/Username." ControlToValidate="emailTextBox1"></asp:RequiredFieldValidator>
<br />
<label>Password</label>
<asp:TextBox ID="passwordTextBox1" runat="server" MaxLength="20" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Please enter your password." ControlToValidate="passwordTextBox1"></asp:RequiredFieldValidator>
<br />
<br />
<div class="checkbox">
<asp:CheckBox ID="remember" runat="server"></asp:CheckBox>
<label for="remember">Remember me on this computer</label>
</div>
<div class="action_btns">
<div class="one_half"><asp:Button id="backButton1" runat="server" Text="Back" BorderStyle="None" CssClass="btn back_btn" EnableTheming="True" Width="150px"></asp:Button></div>
<div class="one_half last"><asp:Button id="loginButton2" runat="server" Text="Login" BorderStyle="None" CssClass="btn btn_red" EnableTheming="True" Width="140px" OnClick="loginButton2_Click"></asp:Button></div>
</div>
</form>
</div>
code for the sign out button :
<div><asp:Button id="signout" CssClass="btn_red" runat="server" Text="Sign-Out" BorderStyle="None" OnClick="signout_Click" EnableTheming="True" ValidateRequestMode="Enabled" /></div>
the asp.net code :
protected void loginButton2_Click(object sender, EventArgs e)
{
if (remember.Checked == true)
{
Response.Cookies["username"].Value = emailTextBox1.Text;
Response.Cookies["username"].Expires = DateTime.Now.AddDays(15);
Response.Cookies["password"].Value = passwordTextBox1.Text;
Response.Cookies["password"].Expires = DateTime.Now.AddDays(15);
if (!string.IsNullOrEmpty(emailTextBox1.Text))
{
modal_trigger.Attributes["Style"] = "display:none";
modal_trigger2.Attributes["Style"] = "display:block";
modal_trigger2.Text = "welcome" + "<br/>" + emailTextBox1.Text;
signout.Attributes["Style"] = "display:block";
}
}
else
{
if (!string.IsNullOrEmpty(emailTextBox1.Text))
{
Session.Add("username", emailTextBox1.Text);
modal_trigger.Attributes["Style"] = "display:none";
modal_trigger2.Attributes["Style"] = "display:block";
modal_trigger2.Text = "welcome" + "<br/>" + Session["username"].ToString();
signout.Attributes["Style"] = "display:block";
}
}
}
protected void signout_Click(object sender, EventArgs e)
{
Response.Cookies["username"].Expires = DateTime.Now.AddDays(-1d);
Response.Cookies["password"].Expires = DateTime.Now.AddDays(-1d);
Response.Cookies.Remove("username");
Response.Cookies.Remove("password");
Session.Abandon();
Session.Clear();
Response.Redirect("default.aspx");
}
}
the login button work but the signout not working.