get HTML elements with C# in ASP.NET
-
Hi community, i'm needing some help with C# and ASP.NET, mostly C# that's why i posted here. I got this form in my login.aspx.
Email: Password: Login [¿Forgot password?](#)
And also i added a database with the SQL EXPRESS. I got the login.aspx.cs with this code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.Sql;
using System.Data.SqlClient;public partial class login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{} private void login\_button(object sender, EventArgs e) { SqlConnection connection = new SqlConnection(); connection.ConnectionString = "Server=(local)\\\\SQLEXPRESS;" + "user ID=myuser; Password=mypassword;" + "Database=mydatabase"; try { connection.Open(); } catch (Exception) { //Not connecting } }
}
Now the question is, how can i get HTML elements with the C#, so then i make the "SELECT Email, Password FROM tblUsers WHERE Email='input_user" AND Password='input_password'" being input_user and input_password C# strings. login_button is the ID of the submit button in ASP.NET. How do i join all this? Getting the number of rows after making the query, like in PHP when you make the $row = sql_query("WHERE...") and returns the number of rows, if $rows == "1", it means that the pair "email and password" exists, so login access is granted. Thanks for everything! Hope you can help me! Marian.
-
Hi community, i'm needing some help with C# and ASP.NET, mostly C# that's why i posted here. I got this form in my login.aspx.
Email: Password: Login [¿Forgot password?](#)
And also i added a database with the SQL EXPRESS. I got the login.aspx.cs with this code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.Sql;
using System.Data.SqlClient;public partial class login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{} private void login\_button(object sender, EventArgs e) { SqlConnection connection = new SqlConnection(); connection.ConnectionString = "Server=(local)\\\\SQLEXPRESS;" + "user ID=myuser; Password=mypassword;" + "Database=mydatabase"; try { connection.Open(); } catch (Exception) { //Not connecting } }
}
Now the question is, how can i get HTML elements with the C#, so then i make the "SELECT Email, Password FROM tblUsers WHERE Email='input_user" AND Password='input_password'" being input_user and input_password C# strings. login_button is the ID of the submit button in ASP.NET. How do i join all this? Getting the number of rows after making the query, like in PHP when you make the $row = sql_query("WHERE...") and returns the number of rows, if $rows == "1", it means that the pair "email and password" exists, so login access is granted. Thanks for everything! Hope you can help me! Marian.
I suggest you move this to the ASP.NET forum (copy there and delete this). You should probably be using ASP.NET web controls in place of the HTML, unless you are using the MVC framework
Sort of a cross between Lawrence of Arabia and Dilbert.[^]
-Or-
A Dead ringer for Kate Winslett[^]