How to display logged in user name on everypage using label but without using loginname control asp.net?
I 开发者_如何学Chave two textbox and a button .... control on web page, ,,,
database structure...
ID Email Password
1 dd@d.com jhatri00
2 ff@f.com tyyuiioo
i want when i login using texxbox1 and textbox2 then it validate emailid and password if record find .... the it will display the emailid on the each page ........ of the logged in username ..... on everypage ...
In the Button's OnClick event, after authenticated, store the email in a Session variable:
public void Button_Click(object o, EventArgs e)
{
string validEmail = ValidateEmail(tbEmail.Text, tbPassword.Text);
if(!string.IsNullOrEmpty)
Session["LoggedOnUser"] = validEmail;
}
Where ValidateEmail(string email, string password) is a method that will actually authenticate the user. Then from whatever page you want the email address to show up just call Session["LoggedOnUser"].ToString()
Edit
Here it is in VB
Public Sub Button_Click(o As Object, e As EventArgs)
Dim validEmail As String = ValidateEmail(tbEmail.Text, tbPassword.Text)
If Not AddressOf String.IsNullOrEmpty Then
Session("LoggedOnUser") = validEmail
End If
End Sub
精彩评论