Forums » .NET » Visual Studio »

login form in C#


Posted Date: 27 Jul 2008      Posted By:: CRPRAJAN     Member Level: Gold    Member Rank: 939     Points: 1   Responses: 2



I am creating a windows login form in visual C# with two textboxes one for accepting the username and other for accepting the password and one button control. I am setting the username as "Rajan" and password as "Admin".

I need to implement the following conditions in my login form.

i)While typing the username, i want the first character alone to get changed into CAPS automatically.
ii)If either the username or the password is wrong then i should get a message box "Invalid login". Else i should get the message "Login Successful".
iii)The application has 2 forms - Form2 and Form3. If the user enters with the "Admin" password then the Form2 should be displayed. Else if the user enters with the password "Guest" then the Form 3 should be displayed. How to do the validation in code.

Can anybody provide the full code?




Responses

#270857    Author: pradipta      Member Level: Gold      Member Rank: 0     Date: 27/Jul/2008   Rating: 2 out of 52 out of 5     Points: 6

Private Sub txtLogin_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtLogin.TextChanged
Dim str As String = txtLogin.Text
If (str.Length > 0) Then
txtLogin.Text = str.Substring(0, 1).ToUpper() & str.Substring(1, str.Length - 1).ToLower
End If
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If txtLogin.Text.Equals("Rajan") AndAlso (txtPassword.Text.Equals("Admin") Or txtPassword.Text.Equals("Guest")) Then
MessageBox.Show("Login Successful")
If (txtPassword.Text.Equals("Admin")) Then
Form2.Show()
Else
Form3.Show()
End If
Else
MessageBox.Show("Invalid Login")
End If
End Sub



 
#271598    Author: Raghuramakarthikeyan      Member Level: Gold      Member Rank: 1849     Date: 28/Jul/2008   Rating: 2 out of 52 out of 5     Points: 6

using System.Windows.Forms;
Private Sub txtLogin_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
{
if(textbox1.text!="" && textbox2.text!="")
{
textbox1.Text = str.Substring(0, 1).ToUpper();
if(textbox1.text=="Rajan")
{
if(textbox2.text=="Admin")
{
Form2.Show();
}
else if(textbox2.text=="Guest")
{
Form3.Show();
}
else
{
MessageBox.Show("Invalid Login")
}
}
else
{
MessageBox.Show("Invalid Login")
}
}
}

this will help you



 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Next : what r various life cycle model in s/w development
Previous : conversion of char* to system::string in vc++ 2005
Return to Discussion Forum
Post New Message
Category:

Related Messages
Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
2005 - 2012 All Rights Reserved.
.NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
Articles, tutorials and all other content offered here is for educational purpose only.
We are not associated with Microsoft or its partners.