To validate login fields use this javascript code
<script language="javascript" type="text/javascript">
function Validation()
{
var userid=document.getElementById('<%=txtUserID.ClientID %>');
var pwd=document.getElementById('<%=txtPwd.ClientID %>');
if(userid.value=="")
{
alert("Please Enter UserID");
userid.focus();
return false;
}
if(pwd.value=="")
{
alert("Please Enter Password");
pwd.focus();
return false;
}
}
</script>
To connect to database refer this link just for idea
http://geekswithblogs.net/dotNETvinz/archive/2009/04/30/creating-a-simple-registration-form-in-asp.net.aspx[
^]
In your login.aspx.cs page write the following code
protected void btnLogin_Click(object sender, EventArgs e)
{
string query = "SELECT USerID,Password WHERE UserID='" + txtUserID.Text + "' AND Password='" + txtPwd.Text + "' AND Active='True'";
SqlDataAdapter da=new SqlDataAdapter(query,connectionstring);
connectionstring.Open();
DataSet ds = new DataSet();
da.Fill(ds);
connectionstring.Close();
ds.Tables[0].TableName = "LoginDetails";
if (ds.Tables["LoginDetails"].Rows.Count > 0)
{
}
else
{
lblError.Text = "UserID or Password are Incorrect";
}
}
This may give you some idea