I am trying to build a simple login form on an existing website I am getting these errors:
txtUser does not exist in the current context
txtPass does not exist in the current context
Literal1 does not exist in the current context
I will paste below first the form, then the codebehind
form
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="logIn.aspx.cs" Inherits="WebApplication1._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
New users can <a href="CarrierRegistration.aspx">register</a> here.<br />
<table border="0" style="border-width: 3px; border-color:#c2c2c2;
border-style: solid;">
<tr>
<td></td>
<td><strong>Please Login</strong></td></tr>
<tr>
<td>
<asp:Label ID="lblUser" runat="server" Text="Username:"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtUser" runat="server"></asp:TextBox>
</td></tr>
<tr>
<td>
<asp:Label ID="lblPass" runat="server" Text="Password:"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtPass" runat="server"></asp:TextBox>
</td></tr>
<tr>
<td></td>
<td>
</td></tr>
<tr>
<td></td>
<td> <asp:Button ID="btnLogin" runat="server" Text="Login"
onclick="btnLogin_Click" /></td></tr>
<tr>
<td>
<asp:Literal ID="Literal1" runat="server"></asp:Literal>
</td></tr>
</table>
</div>
</form>
</body>
</html>
Codebehind
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.OleDb;
namespace WebApplication1
{
public partial class _logIn : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnLogin_Click(object sender, EventArgs e)
{
string connect = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=C:\\Users\\Christie\\Desktop\\WebApplication1\\App_Data\\prosearchusers.mdb";
string query = "Select Count(*) From tblCustRecords Where username = '" & txtUser & "' And [password] = '" & txtPass & "'";
int result = 0;
using (OleDbConnection conn = new OleDbConnection(connect))
{
using (OleDbCommand cmd = new OleDbCommand(query, conn))
{
cmd.Parameters.AddWithValue("Cust_Name", txtUser);
cmd.Parameters.AddWithValue("Cust_Password", txtPass);
conn.Open();
Session["User"] = txtUser;
result = (int)cmd.ExecuteScalar();
}
}
if (result > 0)
{
Response.Redirect("LoggedIn.aspx");
}
else
{
Literal1 = "Invalid login";
}
}
}
}
Can someone please help me, I really do not have much experience in .net programming