Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

Writing Code for LoginStatus and LogoutStatus using C#

$
0
0

My Login Page Controls code is:

<table class="auto-style9">
<tr>
<td class="auto-style12" colspan="2" style="font-family: Georgia; font-size: medium; font-weight: bold; text-transform: uppercase; color: #000000">Login</td>
</tr>
<tr>
<td class="auto-style15">User name</td>
<td class="auto-style15">
<asp:TextBox ID="UserNameTextBox" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style15">Password </td>
<td class="auto-style15">
<asp:TextBox ID="PasswordTextBox" runat="server" TextMode="Password"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style15">&nbsp;</td>
<td class="auto-style15">
<asp:Button ID="ButtonLogin" runat="server" CommandName="Login" Text="Login!" OnClick="ButtonLogin_Click" BackColor="Black" ForeColor="Yellow" />
</td>
</tr>
</table>

My Button Login Click event is :

protected void ButtonLogin_Click(object sender, EventArgs e)
{
using(BerouDataContext Data = new BerouDataContext())
{
var UsernameCheck = UserNameTextBox.Text;
var PasswordCheck = PasswordTextBox.Text;
var UserExist = Data.Memberships.Single(s => s.Username == UsernameCheck);
if (UserExist == null || UserExist.Password != PasswordCheck)
{
LabelLoginValidity.Text = "Login Details are incorrect.";
}
else
{
LabelLoginValidity.Text = "Login Successfull!";
}

My Question is how to make a loginStatus work ? , Please Help me.


Viewing all articles
Browse latest Browse all 23244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>