0% found this document useful (0 votes)
476 views5 pages

Northwind Login Page Implementation

This document contains the code for a login page for a web application. It includes markup for a login form with username and password fields, validation controls, and submission button. In the code-behind, there are event handlers for form submission that validate credentials and redirect or display errors, and a database connection method to check username and password against a stored procedure.

Uploaded by

djahad
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
476 views5 pages

Northwind Login Page Implementation

This document contains the code for a login page for a web application. It includes markup for a login form with username and password fields, validation controls, and submission button. In the code-behind, there are event handlers for form submission that validate credentials and redirect or display errors, and a database connection method to check username and password against a stored procedure.

Uploaded by

djahad
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

<%@ Page language="c#" Codebehind="[Link].

cs" AutoEventWireup="false"
Inherits="NorthCSharp.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="[Link]
<!-- <summary>
||||| Style Sheet |||||
</summary>
--><link title="standard" href="[Link]" type="text/css" rel="stylesheet">
</head>
<body>
<!-- ||||| Login Form ||||| -->
<form id="frmlogin" method="post" runat="server">
<table id="mainTable" border="0">
<tr>
<td>
<table class="t_border" id="loginTable" cellspacing="15"
cellpadding="0">
<tr>
<td><b>Login: </b>
</td>
<td><asp:textbox id="txtUserName" runat="server"
width="160px"></asp:textbox><asp:requiredfieldvalidator id="rvUserValidator"
runat="server" controltovalidate="txtUserName" errormessage="You must supply a
Username!"
display="None"></asp:requiredfieldvalidator></td>
</tr>
<tr>
<td><b>Password: </b>
</td>
<td><asp:textbox id="txtPassword" runat="server" width="160px"
textmode="Password"></asp:textbox><asp:requiredfieldvalidator id="rvPasswordValidator"
runat="server" controltovalidate="txtPassword" errormessage="Empty Passwords not
accepted"
display="None"></asp:requiredfieldvalidator></td>
</tr>
<tr>
<td align="center" colspan="2"><asp:button id="cmdSubmit"
runat="server" text="Submit" borderstyle="Solid"></asp:button></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table id="messageDisplay">
<tr>
<td><asp:validationsummary id="Validationsummary1"
runat="server" width="472px" displaymode="BulletList"></asp:validationsummary></td>
</tr>
</table>
<!--<asp:hyperlink id="hl_Register" runat="server"
navigateurl="[Link]" font-size="X-Small"
height="8px" width="209px" font-names="MS Reference Sans
Serif">New User?...Register Here!</asp:hyperlink>-->
</td>
</tr>
</table>
</form>
<asp:label id="lblMessage" runat="server" width="288px" font-bold="True" font-
italic="True"
font-size="Medium" forecolor="#C00000"></asp:label>
<asp:label id="lblMessage2" runat="server" width="288px" font-bold="True"
font-italic="True"
font-size="Medium" forecolor="#C00000"></asp:label>
<!-- ||||| End of Form ||||| -->
</body>

</html>

using System;
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
// <summmary>
// What has been added for Login Page
// for this application to function
// </summary>
using [Link];
using [Link];
using [Link];

namespace NorthCSharp
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : [Link]
{
protected [Link] txtUserName;
protected [Link] rvUserValidator;
protected [Link] txtPassword;
protected [Link]
rvPasswordValidator;
protected [Link] cmdSubmit;
protected [Link] Validationsummary1;
protected [Link] lblMessage;
protected [Link] lblMessage2;

private void Page_Load(object sender, [Link] 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 [Link] Web Form Designer.
//
InitializeComponent();
[Link](e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
[Link] += new [Link](this.cmdSubmit_Click);
[Link] += new [Link](this.Page_Load);

}
#endregion

private void cmdSubmit_Click(object sender, [Link] e)


{
if ([Link])
{
if (DBConnection([Link](), [Link]()))
{
[Link] ([Link], false);
}
else
{
[Link] = "Invalid Login, please try again!";
}
}

}
private bool DBConnection(string txtUser, string txtPass)
{
SqlConnection myConn = new
SqlConnection([Link]["strConn"]);
SqlCommand myCmd = new SqlCommand("sp_ValidateUser", myConn);
[Link] = [Link];

SqlParameter objParam1;
SqlParameter objParam2;
SqlParameter returnParam;

objParam1 = [Link] ("@UserName", [Link]);


objParam2 = [Link] ("@Password", [Link]);
returnParam = [Link] ("@Num_of_User", [Link]);

[Link] = [Link];
[Link] = [Link];
[Link] = [Link];

[Link] = txtUser;
[Link] = txtPass;

try
{
if ([Link]([Link]))
{
[Link]();
[Link]();
}
if ((int)[Link] < 1)
{
[Link] = "Invalid Login!";
return false;
}
else
{
[Link]();
return true;
}
}
catch (Exception ex)
{
[Link] = ex + "Error Connecting to the database";
return false;
}

}
}

<?xml version="1.0" encoding="utf-8" ?>


<configuration>
<appSettings>
<add key="strConn" value="Network Library=DBMSSOCN;Data
Source=[Link],1433;database=Northwind;User id=;Password=;"/>
</appSettings>
<[Link]>

<!-- DYNAMIC DEBUG COMPILATION


...
...

You might also like