Click here to Skip to main content
15,886,518 members
Articles / Web Development / ASP.NET

How to implement Two basics uses for the Asp.net Login control 2.0 (login and RememberMe)

Rate me:
Please Sign up or sign in to vote.
3.27/5 (32 votes)
23 Nov 20066 min read 404K   72  
This article will show you how to implement two basics uses of the ASP.NET Login control (2.0), The login task itself to validate the users who’s trying to access your web site. In addition i will show how to implement the REMEMBERME process using cookies to save the user name inside the user PC
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace ErikSchmidt
{
	/// <summary>
	/// Summary description for Test1.
	/// </summary>
	public class Test1 : System.Windows.Forms.Form
	{
		private ErikSchmidt.LoginControl loginControl1;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Test1()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.loginControl1 = new ErikSchmidt.LoginControl();
			this.SuspendLayout();
			// 
			// loginControl1
			// 
			this.loginControl1.Check = false;
			this.loginControl1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.loginControl1.Hash = false;
			this.loginControl1.labelButton = "Login";
			this.loginControl1.labelHeader = "Check = False, Hash = False";
			this.loginControl1.labelHeadline = "Test1";
			this.loginControl1.labelPassword = "Password";
			this.loginControl1.labelUsername = "Username";
			this.loginControl1.Name = "loginControl1";
			this.loginControl1.Password = null;
			this.loginControl1.Size = new System.Drawing.Size(460, 300);
			this.loginControl1.TabIndex = 0;
			this.loginControl1.Username = null;
			this.loginControl1.Ready += new System.EventHandler(this.OnReady);
			// 
			// Test1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(452, 296);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																							 this.loginControl1});
			this.Name = "Test1";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "Test1";
			this.ResumeLayout(false);

		}
		#endregion

		private void OnReady(object sender, System.EventArgs e)
		{
			MessageBox.Show("Username: " + loginControl1.Username + "\nPassword: " + loginControl1.Password);
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Colombia Colombia
Web Developer during 3 years and counting, i worked over my school website by two years, right now im webmaster at World Wowan foundation banking in my home city.

Please forgive my pictures examples, they are at spanish language because its my mother language.


Comments and Discussions