Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. get HTML elements with C# in ASP.NET

get HTML elements with C# in ASP.NET

Scheduled Pinned Locked Moved C#
questioncsharpdatabasephphtml
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    msqar
    wrote on last edited by
    #1

    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.

    K 1 Reply Last reply
    0
    • M msqar

      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.

      K Offline
      K Offline
      Keith Barrow
      wrote on last edited by
      #2

      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[^]

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups