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. Web Development
  3. ASP.NET
  4. Create login page using asp.net C#?

Create login page using asp.net C#?

Scheduled Pinned Locked Moved ASP.NET
csharpdatabaseasp-netvisual-studiosysadmin
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.
  • K Offline
    K Offline
    katelva
    wrote on last edited by
    #1

    Hi, I am newbie to asp.net C#, so I am not sure how to read the data from SQL Express database and validate the user input from the database using asp.net C#. Mostly from book and internet are in VB language. I don't want use login control in asp.net C#. The below is I create the main page myself. In vb,I am ok with it but C# not good. Anyone can help and any recommended website for asp.net C#? The bottom is my source code where I have tried to use SQLdataReader: aspx <%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" Title="Untitled Page" %> <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="Main" Runat="Server"> </asp:Content> <asp:Content ID="Content3" ContentPlaceHolderID="Navigation" Runat="Server"> </asp:Content> <asp:Content ID="Content4" ContentPlaceHolderID="Footer" Runat="Server"> </asp:Content> <asp:Content ID="Content5" runat="server" contentplaceholderid="RightTopContent"> <asp:Image ID="Image1" runat="server" Height="26px" Width="162px" /> <br /> Username :<asp:TextBox ID="txtUserName" runat="server"></asp:TextBox> <br /> Password :<asp:TextBox ID="txtPassword" runat="server"></asp:TextBox> <br /> <asp:Button ID="btnSubmit" runat="server" onclick="btnSubmit_Click" Text="Login" /> <br /> </asp:Content> <asp:Content ID="Content6" runat="server" contentplaceholderid="RightMiddleContent"> </asp:Content> <asp:Content ID="Content7" runat="server" contentplaceholderid="MainContent"> </asp:Content> aspx.cs protected void btnSubmit_Click(object sender, EventArgs e) { string uname = txtUserName.Text; string pwd = txtPassword.Text; string connectionString = "Data Source= .\\SQLEXPRESS;" + "AttachDbFilename=\"C:\\Documents and Settings\\kathy\\My Documents\\Visual Studio 2008\\WebSites\\WebSite1\\App_Data\\salon.mdf\";" + "Integrated Security=True;" + "User Instance=True"; SqlConnection myConnection = new SqlConnection(connectionString); SqlCommand cmd = myConnection.CreateCommand(); cmd.CommandText = "SELECT * FROM [Customer]"; myConnection.Open(); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { if (dr.GetOrdinal("UserName").ToString() == txtUserName.Text) { Response.Write("H

    D 1 Reply Last reply
    0
    • K katelva

      Hi, I am newbie to asp.net C#, so I am not sure how to read the data from SQL Express database and validate the user input from the database using asp.net C#. Mostly from book and internet are in VB language. I don't want use login control in asp.net C#. The below is I create the main page myself. In vb,I am ok with it but C# not good. Anyone can help and any recommended website for asp.net C#? The bottom is my source code where I have tried to use SQLdataReader: aspx <%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" Title="Untitled Page" %> <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="Main" Runat="Server"> </asp:Content> <asp:Content ID="Content3" ContentPlaceHolderID="Navigation" Runat="Server"> </asp:Content> <asp:Content ID="Content4" ContentPlaceHolderID="Footer" Runat="Server"> </asp:Content> <asp:Content ID="Content5" runat="server" contentplaceholderid="RightTopContent"> <asp:Image ID="Image1" runat="server" Height="26px" Width="162px" /> <br /> Username :<asp:TextBox ID="txtUserName" runat="server"></asp:TextBox> <br /> Password :<asp:TextBox ID="txtPassword" runat="server"></asp:TextBox> <br /> <asp:Button ID="btnSubmit" runat="server" onclick="btnSubmit_Click" Text="Login" /> <br /> </asp:Content> <asp:Content ID="Content6" runat="server" contentplaceholderid="RightMiddleContent"> </asp:Content> <asp:Content ID="Content7" runat="server" contentplaceholderid="MainContent"> </asp:Content> aspx.cs protected void btnSubmit_Click(object sender, EventArgs e) { string uname = txtUserName.Text; string pwd = txtPassword.Text; string connectionString = "Data Source= .\\SQLEXPRESS;" + "AttachDbFilename=\"C:\\Documents and Settings\\kathy\\My Documents\\Visual Studio 2008\\WebSites\\WebSite1\\App_Data\\salon.mdf\";" + "Integrated Security=True;" + "User Instance=True"; SqlConnection myConnection = new SqlConnection(connectionString); SqlCommand cmd = myConnection.CreateCommand(); cmd.CommandText = "SELECT * FROM [Customer]"; myConnection.Open(); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { if (dr.GetOrdinal("UserName").ToString() == txtUserName.Text) { Response.Write("H

      D Offline
      D Offline
      Domenic Denicola
      wrote on last edited by
      #2

      Check out the <asp:Login /> control (and related), with the only really important event the Authenticate event.

      -Domenic Denicola-

      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