What is Registration Page In ASP.net?
The Registration Page In ASP.net is an excellent way to gather information about your event attendees before they arrive.
A registration page usually has several fields for registrants to fill out with their personal information. These fields can either be required or optional.
What should be on a registration page using ASP.net?
The listed given below are the list of fields inside the registration form.
- Name
- Mobile
- Address
- Username
- Password
Registration Page In ASP.net : About the project
This 2022 article, you will learn on How To Create Registration Form In ASP.net MVC, this Simple Registration Form In ASP.net With SQL Database was developed using ASP.net and SQL Server as the system’s Back-End.
Registration Page In ASP.net MVC : Project Details and Technology
Project Title: | Registration Page Project In ASP.net |
---|---|
Abstract : | Registration Page In ASP.net is an excellent way to gather information about your event attendees before they arrive. |
Project Type: | Website |
Technology : | ASP.Net Visual Studio with C# Language |
Database : | SQL-Server |
To start creating this Registration Page in ASP.net make sure that you have a Microsoft Visual Studio and SQL Server installed in your computer.
Steps on How can create Register page in ASP.net MVC?
Time needed: 5 minutes
These are the steps on how to create a Registration Page In ASP.net With Source Code
- Step 1: Open SQL Server
Open SQL Server (enter the Server Name, Id and Password then click on Connect).
- Step 2: Create new database
Create a new database (right-click on Database then select New Database).
- Step 3: Name your database
Enter “ASPCRUD” for the database name then click OK.
- Step 4: Create new table
Create a new table (explore the CRUD database then right-click on Tables then select New Table).
- Step 5: Design the table
Design the table (name the columns and set the data types as shown in the following figure).
- Step 6: Open Visual Studio
Create a New Web Application (open Visual Studio then select File -> New ->New Project).
- Step 7: Select ASP.NET Web Application
Next, select ASP.NET Web Application(.NET Framework).
- Step 8: Name your project
Next, name your project and then, click create button.
- Step 9: Select empty project
Next, select empty project, then click create.
- Step 10: Add new item
Next, right click on your project name on the right side under solution explorer and click add then new item.
- Step 11: Select web form
Next, select web form the click add and name your form “Contact”
- Step 12 : Add reference
Next, right click the project in the solution explorer then click add the click reference.
- Step 13: Add mysql.data.dll
Next, add mysql.data.dll then click ok.
- Step 14: Copy the code given
Final, copy all code given below and paste it to each designated file.
Registration Page in ASP.net : Contact.aspx
Here’s the code for the Contact.aspx file.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Contact.aspx.cs" Inherits="asp.netcrud.Contact" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:HiddenField ID="hfContactID" runat="server" />
<table>
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text="Name"></asp:Label>
</td>
<td colspan="2">
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label2" runat="server" Text="Mobile"></asp:Label>
</td>
<td colspan="2">
<asp:TextBox ID="txtMobile" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label3" runat="server" Text="Adddress"></asp:Label>
</td>
<td colspan="2">
<asp:TextBox ID="txtAddress" runat="server" TextMode="MultiLine"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label4" runat="server" Text="User Name"></asp:Label>
</td>
<td colspan="2">
<asp:TextBox ID="txtUsername" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label5" runat="server" Text="Password"></asp:Label>
</td>
<td colspan="2">
<asp:TextBox ID="txtPassword" runat="server" TextMode="Password"></asp:TextBox>
</td>
</tr>
<tr>
<td>
</td>
<td colspan="2">
<asp:Button ID="btnSave" runat="server" Text="Register" OnClick="btnSave_Click" />
</td>
</tr>
<tr>
<td>
</td>
<td colspan="2">
<asp:Label ID="lblSuccessMessage" runat="server" Text="" ForeColor="Green"></asp:Label>
</td>
<tr>
<td>
</td>
<td colspan="2">
<asp:Label ID="lblErrorMessage" runat="server" Text="" ForeColor="Red"></asp:Label>
</td>
</tr>
</tr>
</table>
<br />
<asp:GridView ID="gvContact" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Name" />
<asp:BoundField DataField="Mobile" HeaderText="Mobile" />
<asp:BoundField DataField="Address" HeaderText="Address" />
<asp:BoundField DataField="Username" HeaderText="Username" />
<asp:BoundField DataField="Password" HeaderText="Password" />
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>
Registration Page in ASP.net : Contact.aspx.cs
Here’s the code for Contact.aspx.cs file
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace asp.netcrud
{
public partial class Contact : System.Web.UI.Page
{
SqlConnection sqlCon = new SqlConnection(@"Data Source=LAPTOP-AMM1MQ8C;Initial Catalog=ASPCRUD;Integrated Security=true;");
protected void btnClear_Click(object sender, EventArgs e)
{
Clear();
}
public void Clear()
{
hfContactID.Value = "";
txtName.Text = txtMobile.Text = txtAddress.Text = txtUsername.Text = txtPassword.Text = "";
lblSuccessMessage.Text = lblErrorMessage.Text = "";
btnSave.Text = "Register";
}
protected void btnSave_Click(object sender, EventArgs e)
{
if (sqlCon.State == ConnectionState.Closed)
sqlCon.Open();
SqlCommand sqlCmd = new SqlCommand("ContactCreateOrUpdate", sqlCon);
sqlCmd.CommandType = CommandType.StoredProcedure;
sqlCmd.Parameters.AddWithValue("@ConatctID", (hfContactID.Value == "" ? 0 : Convert.ToInt32(hfContactID.Value)));
sqlCmd.Parameters.AddWithValue("@Name", txtName.Text.Trim());
sqlCmd.Parameters.AddWithValue("@Mobile", txtMobile.Text.Trim());
sqlCmd.Parameters.AddWithValue("@Address", txtAddress.Text.Trim());
sqlCmd.Parameters.AddWithValue("@Username", txtUsername.Text.Trim());
sqlCmd.Parameters.AddWithValue("@Password", txtPassword.Text.Trim());
sqlCmd.ExecuteNonQuery();
sqlCon.Close();
string contactID = hfContactID.Value;
Clear();
if (contactID == "")
lblSuccessMessage.Text = "Saved Successfully";
else
lblSuccessMessage.Text = "Updated Successfully";
FillGridView();
}
void FillGridView()
{
if (sqlCon.State == ConnectionState.Closed)
sqlCon.Open();
SqlDataAdapter sqlDa = new SqlDataAdapter("ContactViewAll", sqlCon);
sqlDa.SelectCommand.CommandType = CommandType.StoredProcedure;
DataTable dtbl = new DataTable();
sqlDa.Fill(dtbl);
sqlCon.Close();
gvContact.DataSource = dtbl;
gvContact.DataBind();
}
}
}
Conclusion
Using the .Net Framework 4.7.2 and a code generation tool, we learned how to develop an ASP.NET Web application and link it to a SQL Server to execute basic Registration Form in ASP.net tasks. I hope you found it beneficial.
Please let us know what you think in the comments area below.
Download Source Code below
Anyway, if you want to level up your programming knowledge, especially ASP.net, try this new article I’ve made for you ASP.Net Projects With Source Code For Final Year Students.
Related Articles
- Student Course Registration System Class Diagram | UML
- Simple Registration Form In CodeIgniter With Database
- Registration Form In HTML With Javascript Validation With Source Code
- Registration & Resolution of DependencyService in Xamarin.Forms
- College Registration System Use Case Diagram
- Student Registration System Use Case Diagram
- University Registration system Use Case Diagram
- Student Registration System ER Diagram | Entity Relationship Diagrams
- Login and Registration DFD Levels 0 1 2 | Data Flow Diagrams
- Django Login And Registration With Source Code
- Django Login And Registration With Source Code
- Online Student Registration System Project in PHP Source Code
- Registration Form In Python Using Tkinter With Source Code
- Login User and User Registration in PHP
- Simple Registration Form Source Code in PHP
- Registration Page Using PHP Source Code
- Simple Login & Registration with Logout Using PHP/MYSQL
- LTO Driver’s License Registration System in VB.net with Source Code
- Login User and User Registration in C# and SQL Server 2005
- Validating a Registration Form Using C#
- How to Validate a Registration Form with jQuery, PHP & MySQL database
- Room Registration System In PHP
- Login User and User Registration Form in VB.net
- Saving Data from Registration Form into MySQL using PHP/MySQL
- How to Create a Registration Page Using a Twitter Bootstrap Framework
Inquiries
If you have any questions or suggestions about Registration Page In ASP NET With Source Code, please feel free to leave a comment below.