Create a Login Form in Asp Net With Visual Studio Updated FREE

Create a Login Form in Asp Net With Visual Studio

In this mail we will encounter how to create ASP.Internet Registration course and relieve its data in MS SQL Database. It will be quite simple form with values like Employee Id, Employee name, Appointment of Nativity, State, Land, City names and more. We will be also adding Profile Paradigm of the user and saving it to ASP.NET Project's folder to complete our Registration form data. And so let's see.

Database script and Download link is at the end of the post.

I'm also using AJAX to create this registration grade in ASP.Cyberspace. You can add it to your project by using Visual Studio'southward Nuget Managing director Console.

How to make Registration course in ASP.NET with MS SQL Database
DOWNLOAD SOURCE CODE

First create a new ASP.NET web project in Visual studio. I'm using Visual studio 2017 to create this registration form for ASP.Cyberspace.

Now add a new ASPX class with proper name Registration.aspx and edit it every bit beneath:

Registration.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Registration.aspx.cs" Inherits="RegistrationForms.Registration" ValidateRequest="true"%>  <%@ Register Associates="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %> <!DOCTYPE html>  <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <link href="css/bootstrap.min.css" rel="stylesheet" /> <manner> .borderless td, .borderless thursday { border: none; border-color: Reddish; }  .tabular array-condensed > thead > tr > th, .table-condensed > tbody > tr > thursday, .table-condensed > tfoot > tr > th, .table-condensed > thead > tr > td, .table-condensed > tbody > tr > td, .table-condensed > tfoot > tr > td { padding: 3px; }  input, select { edge-radius: 3px; padding: 1px; border: 1px solid darkgray; }  .btnCoral { groundwork-color: crimson; color: #fff; }  body { /* Permalink - employ to edit and share this gradient: http://colorzilla.com/slope-editor/#1e5799+0,2989d8+50,207cca+51,7db9e8+100;Blue+Gloss+Default */ background: #1e5799; /* Former browsers */ background: -moz-linear-slope(top, #1e5799 0%, #2989d8 50%, #207cca 51%, #7db9e8 100%); /* FF3.6-xv */ background: -webkit-linear-gradient(top, #1e5799 0%,#2989d8 l%,#207cca 51%,#7db9e8 100%); /* Chrome10-25,Safari5.1-6 */ background: linear-slope(to bottom, #1e5799 0%,#2989d8 l%,#207cca 51%,#7db9e8 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1e5799', endColorstr='#7db9e8',GradientType=0 ); /* IE6-nine */ }  .parent-container { groundwork-color: black; width:70%; }  .container { background-color: white; margin:2px; width:motorcar; }  </fashion> <championship>Registration Form</title> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager runat="server" /> <div class="parent-container"> <div course="container"> <table grade="table-condensed borderless"> <tr> <td align="center" colspan="ii"> <h2 style="background-color: black; color: White; padding: 5px;">REGISTRATION Class</h2> </td> </tr> <tr> <td align="correct">EMP Id:</td> <td marshal="left"> <asp:TextBox runat="server" ID="txtEmpId" /> <asp:RequiredFieldValidator runat="server" ControlToValidate="txtEmpId" ErrorMessage="*" ForeColor="Red" ValidateRequestMode="Enabled"/> </td> </tr> <tr> <td align="correct">Name:</td> <td align="left"> <asp:TextBox runat="server" ID="txtName" /> <asp:RequiredFieldValidator runat="server" ControlToValidate="txtName" ErrorMessage="*" ForeColor="Blood-red" /> </td> </tr> <tr> <td marshal="right">Appointment of Birth:</td> <td marshal="left"> <asp:TextBox runat="server" ID="txtDOB" /> <ajax:CalendarExtender runat="server" Format="yyyy-MM-dd" TargetControlID="txtDOB" />  <asp:RequiredFieldValidator runat="server" ControlToValidate="txtDOB" ErrorMessage="*" ForeColor="Red" /> </td> </tr> <tr> <td align="right">Accost:</td> <td marshal="left"> <asp:TextBox runat="server" ID="txtAddress" /> <asp:RequiredFieldValidator runat="server" ControlToValidate="txtAddress" ErrorMessage="*" ForeColor="Red" /> </td> </tr> <tr> <td align="right">Country:</td> <td align="left"> <asp:DropDownList runat="server" ID="ddCountry" AutoPostBack="truthful" OnSelectedIndexChanged="ddCountry_SelectedIndexChanged" /></td> </tr> <tr> <td marshal="right">State:</td> <td marshal="left"> <asp:DropDownList runat="server" ID="ddState" AutoPostBack="true" OnSelectedIndexChanged="ddState_SelectedIndexChanged" /></td> </tr> <tr> <td align="right">City:</td> <td align="left"> <asp:DropDownList runat="server" ID="ddCity" /></td> </tr> <tr> <td align="right">Pincode:</td> <td marshal="left"> <asp:TextBox runat="server" ID="txtPincode" /> <asp:RequiredFieldValidator runat="server" ControlToValidate="txtPincode" ErrorMessage="*" ForeColor="Red" /> </td> </tr> <tr> <td align="right">Date of Joining:</td> <td align="left"> <asp:TextBox runat="server" ID="txtDOJ" /> <ajax:CalendarExtender runat="server" Format="yyyy-MM-dd" TargetControlID="txtDOJ" /> <asp:RequiredFieldValidator runat="server" ControlToValidate="txtDOJ" ErrorMessage="*" ForeColor="Cherry-red" /> </td> </tr> <tr> <td align="right">Department:</td> <td align="left"> <asp:DropDownList runat="server" ID="ddDepartment" /></td> </tr> <tr> <td align="right">Part:</td> <td marshal="left"> <asp:DropDownList runat="server" ID="ddRole">  <asp:ListItem Text="USER" Value="USER" /> <asp:ListItem Text="ROLE" Value="ROLE" />  </asp:DropDownList></td> </tr> <tr> <td align="right">Profile Pic:</td> <td align="left" valign="eye"> <asp:FileUpload runat="server" ID="fileUpload" /> <asp:Button runat="server" Text="Upload" ID="btnUpload" OnClick="btnUpload_Click" />  <asp:Epitome ID="imgProfile" runat="server" Width="150px" Top="150px" /> </td> </tr>  <tr> <td align="right">Email ID:</td> <td marshal="left"> <asp:TextBox runat="server" ID="txtEmail" /> <asp:RequiredFieldValidator runat="server" ControlToValidate="txtEmail" ErrorMessage="*" ForeColor="Red" /> <asp:RegularExpressionValidator runat="server" ValidationExpression="\due west+([-+.]\w+)*@\due west+([-.]\w+)*\.\w+([-.]\due west+)*" ControlToValidate="txtEmail" ErrorMessage="Email address invalid" /> </td> </tr> <tr> <td align="correct">Password:</td> <td marshal="left"> <asp:TextBox runat="server" ID="txtpassword" TextMode="Password"/> <asp:RequiredFieldValidator runat="server" ControlToValidate="txtpassword" ErrorMessage="*" ForeColor="Crimson" /> </td> </tr> <tr> <td marshal="right">Confirm Password:</td> <td align="left"> <asp:TextBox runat="server" ID="txtConfirmPassword" TextMode="Countersign"/></td> </tr> <tr> <td colspan="20"> <asp:CompareValidator ID="comparePasswords" runat="server" ControlToCompare="txtpassword" ControlToValidate="txtConfirmPassword" ErrorMessage="Passwords practise not lucifer up." ForeColor="Red" /> </td> </tr> <tr> <td colspan="2" align="middle"> <br /> <asp:Button runat="server" ID="btnSubmit" Text="Submit" OnClick="btnSubmit_Click" CssClass="btn btnCoral" /> </td> </tr> <tr> <td colspan="2"> <asp:Label runat="server" ID="lblInfo" /> </td> </tr> </tabular array> </div>  </div> </grade> </torso> </html>        

form layout registration form

Ajax's Information picker is used to prepare Date of Nascency and Date of Joining information of the employee to complete the registration process.

Contour moving-picture show will be saved inside "ProfileImages" folder.

registration page folder info

And below is my code for the registration page:

Registration.aspx.cs:

using Arrangement; using System.Data.SqlClient; using System.Data; using System.Configuration; using System.IO; using System.Web.UI;  namespace RegistrationForms { public partial class Registration : Organisation.Web.UI.Folio { SqlConnection con; SqlCommand cmd; SqlDataAdapter adapter; SqlDataReader reader; DataSet ds; DataTable dt;  protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { LoadCountries(); LoadDepartment(); } }  public void LoadDepartment() { try { con = new SqlConnection(ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString); cmd = new SqlCommand("Select * from tblDepartments", con); con.Open up(); adapter = new SqlDataAdapter(cmd); dt = new DataTable(); adapter.Make full(dt);  if (dt.Rows.Count > 0) { DataRow dr = dt.NewRow(); dr["DeptId"] = 0; dr["Department"] = "Please select Department"; dt.Rows.InsertAt(dr, 0);  ddDepartment.DataSource = dt; ddDepartment.DataTextField = "Department"; ddDepartment.DataValueField = "DeptId"; ddDepartment.DataBind(); } adapter.Dispose(); cmd.Dispose(); con.Close(); } grab (Exception ex) { lblInfo.Text = ex.Bulletin.ToString(); } } public void LoadCountries() { try { con = new SqlConnection(ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString); cmd = new SqlCommand("Select * from tblCountries", con); con.Open up(); adapter = new SqlDataAdapter(cmd); dt = new DataTable(); adapter.Fill(dt);  if (dt.Rows.Count > 0) { DataRow dr = dt.NewRow(); dr["CountryId"] = 0; dr["Country"] = "Delight select Country"; dt.Rows.InsertAt(dr, 0);  ddCountry.DataSource = dt; ddCountry.DataTextField = "Country"; ddCountry.DataValueField = "CountryId"; ddCountry.SelectedIndex = 0; ddCountry.DataBind(); } adapter.Dispose(); cmd.Dispose(); con.Close(); } catch (Exception ex) { lblInfo.Text = ex.Message.ToString(); }  } protected void btnSubmit_Click(object sender, EventArgs eastward) { try { if (Page.IsValid) { con = new SqlConnection(ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString); cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "sp_AddUsers"; cmd.Connection = con; cmd.Parameters.AddWithValue("@UserId", txtEmpId.Text.ToString()); cmd.Parameters.AddWithValue("@Proper noun", txtName.Text.ToString()); cmd.Parameters.AddWithValue("@DOB", txtDOB.Text.ToString()); cmd.Parameters.AddWithValue("@Address", txtAddress.Text.ToString()); cmd.Parameters.AddWithValue("@City", ddCity.SelectedValue.ToString()); cmd.Parameters.AddWithValue("@State", ddState.SelectedValue.ToString()); cmd.Parameters.AddWithValue("@State", ddCountry.SelectedValue.ToString()); cmd.Parameters.AddWithValue("@Pincode", txtPincode.Text.ToString()); cmd.Parameters.AddWithValue("@Department", ddDepartment.SelectedValue.ToString()); cmd.Parameters.AddWithValue("@UserRole", ddRole.SelectedItem.Text.ToString()); cmd.Parameters.AddWithValue("@Passcode", txtpassword.Text.ToString()); cmd.Parameters.AddWithValue("@DOJ", txtDOJ.Text.ToString()); cmd.Parameters.AddWithValue("@ProfilePic", imgProfile.ImageUrl.ToString()); cmd.Parameters.AddWithValue("@EmailId", txtEmail.Text.ToString()); con.Open(); cmd.ExecuteNonQuery(); cmd.Dispose(); con.Close(); ShowAlert("Success", "Saved Successfully"); ClearFeilds(); } else ShowAlert("Error", "Delight enter all fields"); } catch (Exception ex) {  } }  public void ShowAlert(String header, String message) { ScriptManager.RegisterStartupScript(this, GetType(), header, "alert('" + message + "');", true); }  public void ClearFeilds() { txtAddress.Text = ""; txtConfirmPassword.Text = ""; txtDOB.Text = ""; txtDOJ.Text = ""; txtEmail.Text = ""; txtEmpId.Text = ""; txtName.Text = ""; txtpassword.Text = ""; txtPincode.Text = ""; LoadCountries(); } protected void ddCountry_SelectedIndexChanged(object sender, EventArgs e) { LoadState(); }  public void LoadState() { try { con = new SqlConnection(ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString); cmd = new SqlCommand("Select * from tblStates where CountryId=@id", con); cmd.Parameters.AddWithValue("@id", ddCountry.SelectedValue.ToString()); con.Open up(); adapter = new SqlDataAdapter(cmd); dt = new DataTable(); adapter.Fill(dt);  if (dt.Rows.Count > 0) { DataRow dr = dt.NewRow(); dr["StateId"] = 0; dr["Country"] = "Delight select State"; dr["CountryId"] = "0"; dt.Rows.InsertAt(dr, 0); ddState.Items.Clear(); ddState.ClearSelection(); ddState.DataSource = dt; ddState.DataTextField = "Country"; ddState.DataValueField = "StateId"; ddState.DataBind(); ddState.SelectedValue = null; ddState.SelectedIndex = 0; ddCity.Items.Articulate(); ddCity.SelectedValue = nil; } adapter.Dispose(); cmd.Dispose(); con.Close(); } catch (Exception ex) { } }  protected void ddState_SelectedIndexChanged(object sender, EventArgs e) { try { con = new SqlConnection(ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString); cmd = new SqlCommand("Select * from tblCities where Stateid=@id", con); cmd.Parameters.AddWithValue("@id", ddState.SelectedValue.ToString()); con.Open up(); adapter = new SqlDataAdapter(cmd); dt = new DataTable(); adapter.Fill(dt);  if (dt.Rows.Count > 0) { DataRow dr = dt.NewRow(); dr["CityId"] = 0; dr["Metropolis"] = "Please select City"; dr["StateId"] = "0"; dt.Rows.InsertAt(dr, 0); ddCity.DataSource = null; ddCity.DataSource = dt; ddCity.DataTextField = "City"; ddCity.DataValueField = "CityId"; ddCity.DataBind(); ddCity.SelectedValue = nil; ddCity.SelectedIndex = 0; } adapter.Dispose(); cmd.Dispose(); con.Shut(); } grab (Exception ex) { } }  protected void btnUpload_Click(object sender, EventArgs due east) { try { if (fileUpload.HasFile) { string fileName = Path.GetFileName(fileUpload.PostedFile.FileName); fileUpload.PostedFile.SaveAs(Server.MapPath("~/ProfileImages/") + fileName); imgProfile.ImageUrl = "~/ProfileImages/" + fileName; } } catch (Exception ex) { lblInfo.Text = "Image upload: " + ex.Bulletin.ToString(); } } } }        

Below is the Database script (MS SQL Database):

--Create database [ESource] USE [ESource]  CREATE TABLE [dbo].[tblStates]( [StateId] [int] IDENTITY(i,one) Non Goose egg, [State] [nvarchar](50) Not Zip, [CountryId] [int] Not Zilch )  CREATE TABLE [dbo].[tblCities]( [CityId] [int] IDENTITY(1,1) Not Naught, [City] [nvarchar](50) Not Nothing, [StateId] [int] Non Zero )  CREATE Tabular array [dbo].[tblCountries]( [CountryId] [int] IDENTITY(1,i) NOT Null, [Country] [nvarchar](l) Not NULL )  CREATE TABLE [dbo].[tblDepartments]( [DeptId] [int] IDENTITY(1,ane) NOT NULL, [Section] [nvarchar](l) NOT Zip )  CREATE TABLE [dbo].[tblUserDetails]( [EId] [int] IDENTITY(1,ane) Non NULL, [EmailId] [nvarchar](50) Not NULL, [UserId] [nvarchar](50) NULL, [Passcode] [nvarchar](50) NOT Nothing, [Proper name] [nvarchar](fifty) NOT NULL, [DOB] [datetime] Not Naught, [Address] [nvarchar](max) Non NULL, [City] [nvarchar](l) NOT Zip, [Pincode] [int] NOT Zippo, [State] [nvarchar](50) NOT NULL, [State] [nvarchar](50) Not Nix, [Department] [nvarchar](50) Non Zilch, [DOJ] [datetime] Not Zilch, [ProfilePic] [nvarchar](max) NOT NULL, [UserRole] [nvarchar](50) )  CREATE procedure [dbo].[sp_AddUsers] ( @UserId nvarchar(50), @Passcode nvarchar(50), @Name nvarchar(50), @DOB datetime, @Address nvarchar(max), @Urban center int, @Pincode nvarchar(l), @State int, @State int, @Department int, @DOJ datetime, @ProfilePic nvarchar(max), @UserRole nvarchar(l), @EmailId nvarchar(fifty) ) equally begin Insert into tblUserDetails (UserId,Passcode,Name,DOB,Address,City,Pincode,State,Country,Section,DOJ,ProfilePic,UserRole,EmailId) values (@UserId,@Passcode,@Name,@DOB,@Accost,@City,@Pincode,@State,@Country,@Section,@DOJ,@ProfilePic,@UserRole,@EmailId); end GO        

DOWNLOAD SOURCE CODE

Create a Login Form in Asp Net With Visual Studio

DOWNLOAD HERE

Source: https://parallelcodes.com/how-to-create-registration-form-in-asp-net-with-ms-sql-database/

Posted by: kylewasuch.blogspot.com

Comments

Popular

Блогер Волошин : Блогер Волошин отбирает у девочки айфон.Неудавшийся пранкк ...

Car Lifts For 10' Ceilings : Best Two-Post Lift for Low Ceilings by BendPak

Нани Брегвадзе / Дискография Нани Брегвадзе




banner



Featured Post

How to Improve Your Self Esteem as a Woman

Image
How to Improve Your Self Esteem as a Woman Are you curious to know how to build confidence as a woman? Do you lack self-esteem and confidence as a lady? Mayhap in that location are things you want to do with your life but you lot lack the confidence to take action on your goals? Do you lot always feel shy, intimidated, afraid, and insecure? Do you wish you tin be more cocky-confident just like other confident people you know and admire? If this yous, then you've plant this just at the correct time. Here, nosotros'll share effective tips that would give you the conviction boost you need to beat cocky-incertitude and insecurity. Read on till the cease. How To Build Confidence Every bit A Woman