- sourcecode.zip
- SourceCode
- Csharp
- Components
- Business
- Data
- Interface
- Parent
- Web
- CSS
- Errors
- Images
- bg_navigation.gif
- delete.gif
- logobanner.gif
- new.gif
- top.jpg
- update.gif
- Login
- UserControls
- Scripts
- ThreeTierGenerator
- VB
- Components
- Business
- Data
- Interface
- Parent
- Web
- CSS
- Errors
- Images
- bg_navigation.gif
- delete.gif
- new.gif
- top.jpg
- update.gif
- UserControls
- demo.zip
- Demo
- ThreeTierDemo
- ThreeTierDemoVB
|
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace WebChamps.Login
{
/// <summary>
/// Summary description for Login.
/// </summary>
public class Login : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lblMessage;
protected System.Web.UI.WebControls.TextBox txtUsername;
protected System.Web.UI.WebControls.RequiredFieldValidator Requiredfieldvalidator1;
protected System.Web.UI.WebControls.TextBox txtPassword;
protected System.Web.UI.WebControls.RequiredFieldValidator Requiredfieldvalidator2;
protected System.Web.UI.WebControls.Button btnLogin;
protected System.Web.UI.HtmlControls.HtmlForm Form1;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void btnLogin_Click(object sender, System.EventArgs e)
{
if (IsValid)
{
if (DBAuthenticate(txtUsername.Text, txtPassword.Text) > 0 )
{
System.Web.Security.FormsAuthentication.RedirectFromLoginPage(txtUsername.Text, false); }
}
}
private int DBAuthenticate(String strUsername, String strPassword)
{
String strConString;
System.Data.SqlClient.SqlConnection conOnlineStore;
System.Data.SqlClient.SqlCommand cmdSelect;
System.Data.SqlClient.SqlParameter parmReturnValue;
int intResult;
strConString = System.Configuration.ConfigurationSettings.AppSettings["connectionString"];
conOnlineStore = new System.Data.SqlClient.SqlConnection(strConString);
cmdSelect = new System.Data.SqlClient.SqlCommand("ProcAuthenticate", conOnlineStore);
cmdSelect.CommandType = CommandType.StoredProcedure;
parmReturnValue = cmdSelect.Parameters.Add("RETURN_VALUE", SqlDbType.Int);
parmReturnValue.Direction = ParameterDirection.ReturnValue;
cmdSelect.Parameters.Add("@proc_username", strUsername);
cmdSelect.Parameters.Add("@proc_password", strPassword);
conOnlineStore.Open();
cmdSelect.ExecuteNonQuery();
intResult = (int)cmdSelect.Parameters["RETURN_VALUE"].Value;
conOnlineStore.Close();
if( intResult < 0 )
{
if (intResult == -1)
{
lblMessage.Text = "Username Not Registered!";
}
else
{
lblMessage.Text = "Invalid Password!";
}
}
return intResult;
}
private void btnLogin_Click()
{
}
}
}
|
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.
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
Stevan is a Microsoft Certified Solutions Developer in .Net Architecture (MCSD.Net Early Achiever – one among the first 2500 worldwide), Microsoft Certified Application Developer in .Net – MCAD.Net (Charter Member - one among the first 5000 developers worldwide).