0% found this document useful (0 votes)
88 views

User, Password Verification: Body Form Div Asp Textbox Asp Textbox Asp Label

The document contains source code for user password verification in ASP.NET. It includes the Default.aspx code which contains textboxes and labels for the user name and password, and a submit button. The Default.aspx.cs code behind connects to a SQL database called "vinod" and queries the "AdminUser" table to verify if the user name and password match any rows, and displays if login was successful or not.

Uploaded by

srihari595
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
88 views

User, Password Verification: Body Form Div Asp Textbox Asp Textbox Asp Label

The document contains source code for user password verification in ASP.NET. It includes the Default.aspx code which contains textboxes and labels for the user name and password, and a submit button. The Default.aspx.cs code behind connects to a SQL database called "vinod" and queries the "AdminUser" table to verify if the user name and password match any rows, and displays if login was successful or not.

Uploaded by

srihari595
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 6

User, password verification

Source code (Default.aspx)

<body>
<form id="form1" runat="server">
<div>

<asp:TextBox ID="txtUserName" runat="server"


style="top: 16px; left: 186px; position: absolute;
height: 22px; width: 128px"></asp:TextBox>
<asp:Label ID="lblUserName" style="position:absolute;
top: 19px; left: 59px;"
runat="server" Text="User Name" Font-Bold="True"
Font-Italic="True"
Font-Size="Large" ForeColor="#FF3399"></asp:Label>
<br />
<br />
<asp:TextBox ID="txtPassword" runat="server"
style="top: 67px; left: 186px; position: absolute;
height: 22px; width: 128px"
TextMode="Password"></asp:TextBox>
<br />
<br />
<asp:Button ID="btnSubmit" runat="server"
onclick="btnSubmit_Click"
style="top: 125px; left: 195px; position: absolute;
height: 26px; width: 61px"
Text="Submit" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label1" style="position:absolute; top:
122px; left: 335px;"
runat="server" Text="Label"></asp:Label>

</div>
<p>
<asp:Label ID="lblPassword" style="position:absolute;
top: 64px; left: 59px;"
runat="server" Text="Password" Font-Bold="True" Font-
Italic="True"
Font-Size="Large" ForeColor="#FF3399"></asp:Label>
</p>
</form>
</body>
</html>

Default.aspx.cs

using System;
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.SqlClient;

public partial class _Default : System.Web.UI.Page


{
SqlConnection con;
SqlCommand cmd;
protected void Page_Load(object sender, EventArgs e)
{

}
protected void btnSubmit_Click(object sender, EventArgs e)
{
con = new SqlConnection("Data Source=COMPUTER-
A7D401\\SQLEXPRESS;Initial Catalog=vinod;Integrated
Security=True");
con.Open();
cmd = new SqlCommand("select * from AdminUser where
UserName=@UserName and Password=@Password",con);
//cmd.Parameters.Add("@UserName",
SqlDbType.VarChar).Value = txtUserName.Text;
//cmd.Parameters.Add("@Password",
SqlDbType.VarChar).Value = txtPassword.Text;
cmd.Parameters.Add("@UserName", txtUserName.Text);
cmd.Parameters.Add("@Password", txtPassword.Text);
SqlDataReader rec;
rec = cmd.ExecuteReader();
rec.Read();

if (rec.HasRows)
{
Label1.Text = "successfully";
}
else
{
Label1.Text = "User not found";
}

}
}

Data Base

You might also like