<%@ Page Title="" Language="C#" MasterPageFile="~/Master/MasterPage.master" AutoEventWireup="true" CodeFile="login.aspx.cs" Inherits="login" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<style type="text/css">
label {
width:130px; /*Or however much space you need for the form’s labels*/
float:left;
}
i
{
color:Red;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:LoginView ID="LoginView1" runat="server">
<AnonymousTemplate>
<div style="margin-left: 300px;margin-top: 100px">
<table style="border: 2px solid #000;background-color:#CCFF66;">
<tr>
<th>Homezid.com Login</th></tr>
<tr>
<td><label><i>*</i> Email</label><asp:TextBox ID="email" BackColor="#FFFF99" runat="server"></asp:TextBox></td></tr>
<tr>
<td><label><i>*</i> Password</label><asp:TextBox ID="password" TextMode="Password" BackColor="#FFFF99" runat="server"></asp:TextBox><br /></td></tr>
<tr><td align="center">
<asp:Button ID="Loginsite" runat="server" Text="Login"
onclick="Loginsite_Click" /></td>
</tr>
<tr><td>
<asp:Label ID="errormessage" ForeColor="Red" runat="server" Text=""></asp:Label></td>
</tr>
<tr><td>
<asp:HyperLink ID="HyperLink1" NavigateUrl="~/register.aspx" runat="server">Register Account</asp:HyperLink></td>
<td><asp:HyperLink ID="HyperLink2" runat="server">Forgot Password?</asp:HyperLink></td>
</tr>
</table>
</div>
</AnonymousTemplate>
<LoggedInTemplate>
<asp:LoginStatus ID="LoginStatus1" runat="server" />
</LoggedInTemplate>
</asp:LoginView>
</asp:Content>
login.aspx.cs
using System;
using System.Configuration;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class login : System.Web.UI.Page
{
SqlConnection connect;
SqlDataReader reader;
SqlCommand command;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Loginsite_Click(object sender, EventArgs e)
{
connect= new SqlConnection("Server=localhost\\SqlExpress;Database=VoteNow;" + "Integrated Security=True");
command = new SqlCommand("SELECT email,password FROM registration WHERE [email]=@email AND [password]=@password",connect);
command.Parameters.AddWithValue("@email", email.Text);
command.Parameters.AddWithValue("@password", password.Text);
connect.Open();
reader = command.ExecuteReader(Commandbehavior.CloseConnection);
if (email.Text=="" || password.Text == "")
{
errormessage.Text = " Please fillout the email and/or password";
}
else if (reader.Read())
{
FormsAuthentication.RedirectFromLoginPage(email.Text, true);
Response.Redirect("edit.aspx");
}
else
{
errormessage.Text= "Email or Password is invalid";
}
connect.Close();
}
}
I am receiving an error with the email.text ,password.text , errormessage.text

New Topic/Question
Reply




MultiQuote





|