Login Control in Visual Studio 2005
As the name implies login control provides GUI to log into a website. As we develop websites login feature is quite common functionality in each and every website.
I have developed more than 10 web applications and all of them has login feature as common. So In VS2005 Microsoft made the job of the developer easy by introducing Login Controls. This reduces coding as well as development cost.
It comes with two labels, two textboxes one for entering UserId and the other for entering password, along with a login button. We can customize the control using auto format. Instruction text and Title text are there to write specific notes that may act as guide to the user. CreateUserText , HelpPageText, PasswordRecoveryText are some of the properties of the login Control that are used to specify text for creating new user, HelpText and the text for password recovery respectively. We can even change the username and password labels. If we enable ‘RememberMeSet’ property to true then remember me check box highlights .By default it’s true.
VIsibleWhenLoggedIn set to true, the control will be hidden on the page if the user is already authenticated. This option very much useful in designing live websites that provides personalized data when the user is logged in to the website.
Implementation
Create a new VS2005 Website. Add a login control from login tab in VS2005 toolbar. I have just given it’s user text for PasswordrecoveryText and CreateUserText and given the corresponding URLs in links Section.
Now Double click on the control. You will be redirected to Authenticate event of Login control in code behind.
Now we need to write code for authenticating a user
}
private bool ValidateLogIn(string UserName, string Password)
{
bool blnRetVal = false;
string strConnection = “data source=HIMABINDU;database=Test;uid=sa;pwd=;”;
SqlConnection Connection = new SqlConnection(strConnection);
String strSQL = “Select UserId,Password From UserMaster where UserId =+â€â€™UserName’†+ and Password =+â€â€™Password’â€;
SqlCommand command = new SqlCommand(strSQL, Connection);
SqlDataReader dr;
Connection.Open();
dr = command.ExecuteReader();
while (dr.Read())
{
if ((UserName == dr[0].ToString()) & (Password == dr[1].ToString()))
{
blnRetVal = true;
}
}
dr.Close();
return blnRetVal;
}
Conclusion
The above code is self explanatory. We need to check UserId and Password from database and if it’s matches correctly then ValidateLogin returns true .Otherwise it returns false. It accepts UserId and password fields that we need to pass dynamically as Login1.UserId, Login1.Password that’s it.
If the user is present in Database it returns true else it returns false.This article described usage of login control and authenticating user.
Copyright @ HimaBindu Veeramachaneni 2007

- ASP.NET Breadcrumbs with C#
- Creating an object oriented MySQL abstraction class
- Easiest way to implement Ajax in your ASP.Net 2.0 applications
- Encrypt Connection String in Web.Config
- AJAX Generic Form Parser - With Validation
- Get Google Adsense statistics by using PHP
- Practical Implementation of MSMQ Using ASP.Net and SQL Server
- Using PHP to get prices from Amazon.com
- 8 Essential MySQL Queries
- Edit and Encrypt Web.Config sections using C# 2.0
- The Ocean Girl Photo Effect
- Create flaming meteor
- Create sci-fi poster art in Photoshop
- Create Sketchy-Style Vectors
- Realistic Fire
- 10 Techniques That are Essential For Successful Photo Manipulation Artwork
- Rusted Metal Art
- Creat a Vibrant digital Collage Mixing Buildings and Vector Shapes on Paper
- Stars Photoshop & GIMP Brushes
- Add A Realistic Water Reflection
Login
Friends' Sites
Contact Us
Categories
- 3D
- ASP
- C#
- CSS
- Database
- Flash
- GIMP
- Hosting
- Illustrator
- Java
- Javascript
- Linux
- Photoshop
- PHP
- Web Design
- Windows

2,756 views
2 Comments
(2 votes, average: 4 out of 5)
2 Comments
Jump to comment form | comments rss [?] | trackback uri [?]