Below are my code: HTML: <asp:Button ID="btnLogin" runat="server" Text="Login" class="button" OnClientClick="return validateTextPw()" OnClick="btnLogin_Click" formmethod="post" /> C#: protected void btnLogin_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MmrtgDBConnString"].ConnectionString); con.Open(); SqlCommand cmd = new SqlCommand("select * from MSTR_USER where UserId =@username and UserPassword=@password", con); cmd.Parameters.AddWithValue("@username", txtUserId.Value); cmd.Parameters.AddWithValue("@password", txtPsd.Value); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count > 0) { Response.Redirect("Login.aspx"); } else { ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language='javascript'>alert('Invalid Username and Password')</script>"); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)