BestCloudHostingASP.NET | Best and affordable ASP.NET Hosting. Today I will share tutorial about how to creating registration and login page in ASP.NET ??? Ok Let me to show you.

  • We first open Visual Studio 2013 as administrator and create a new website. Create using File -> New -> Website. From the Visual C#  tab select the ASP.NET Empty Web Site and click on the OK button.
  • After creating the website the next step is to add a web form to this website. Right-click on the website and add a Web Form to the website.
  • In the Design page we have used three labels, three textboxes and two buttons. One is for the Registration and the other one is for the Login. Now provide the name of labels and buttons, depending on your requirements.
  • Now create the table into the SQL Server database and take the three fields. The fields are username, password and email fields. The code looks as in this:
create table registration  
(  
   Username varchar(100),  
   Email varchar(100),  
   Password varchar(20)  
)

 Stored Procedure for the table:

    create procedure [dbo].[strlogin]  
    (  
       @username varchar(40),  
       @email varchar(50),  
       @password varchar(20)  
    )  
    as  
    insert into registration values(@username,@email,@password )

 We now double-click on the button and use the following code:

protected void Button1_Click(object sender, EventArgs e)  
{  
    string strcon = "Data Source=.;uid=sa;pwd=Password$2;database=roham";  
    SqlConnection con = new SqlConnection(strcon);  
    SqlCommand com = new SqlCommand("CUser", con);  
    com.CommandType = System.Data.CommandType.StoredProcedure;  
    SqlParameter p1 = new SqlParameter("username", TextBoxusername.Text);  
    SqlParameter p2 = new SqlParameter("password", TextBoxpassword.Text);  
    com.Parameters.Add(p1);  
    com.Parameters.Add(p2);  
    con.Open();  
    SqlDataReader rd = com.ExecuteReader();  
    if (rd.HasRows)  
    {  
        rd.Read();  
        Label3.Text = "Login successful.";  
        Label3.Visible = true;  
    }  
    else  
    {  
        Label3.Text = "Invalid username or password.";  
        Label3.Visible = true;  
    }  
}

For login we create an another webform and now right-click on the website.
Add a new form and provide the name, whatever you want.

Now create a Stored Procedure for the login page as in the following:

    create PROCEDURE CUser  
    (  
       @username as varchar(50),  
       @password as varchar(50)  
    )  
    SELECT * FROM registrationtab WHERE username=@username AND password=@password

 Now we double-click on the login button and write the following code:

protected void Button1_Click(object sender, EventArgs e)  
{  
    string strcon = "Data Source=.;uid=sa;pwd=Password$2;database=roham";  
    SqlConnection con = new SqlConnection(strcon);  
    SqlCommand com = new SqlCommand("CUser", con);  
    com.CommandType = System.Data.CommandType.StoredProcedure;  
    SqlParameter p1 = new SqlParameter("username", TextBoxusername.Text);  
    SqlParameter p2 = new SqlParameter("password", TextBoxpassword.Text);  
    com.Parameters.Add(p1);  
    com.Parameters.Add(p2);  
    con.Open();  
    SqlDataReader rd = com.ExecuteReader();  
    if (rd.HasRows)  
    {  
        rd.Read();  
        Label3.Text = "Login successful.";  
        Label3.Visible = true;  
    }  
    else  
    {  
        Label3.Text = "Invalid username or password.";  
        Label3.Visible = true;  
    }  
}

 Now run the application by pressing the F5 key.

I hope this article is helpful for the readers that want to simply create a registration and login page in ASP.NET. Thanks for reading this article, I hope you like it.

Happy Coding :)

TOP 3 Recommendation Best ASP.NET 5 Hosting

 

asphostportal-icon-e1421832425840-120x120ASPHostPortal.com is a windows-based hosting service provider. ASPHostPortal.com offers the most best and affordable ASP.NET 5 hosting infrastructure on the net with great features, fast and secure servers. they hosting can be done via USA, Amsterdams or Singapore based server. Depending your requirements, they can scale so we can deliver the right service for the right price. All of their windows hosting plan supports ASP.NET 5 and you can install ASP.NET with just one click.

ASPHostPortal has been in the industry for many years, followed by numerous loyal webmasters around the world. Among all the companies we have reviewed, this company offers the fastest hosting speed by using 5 first-class data centers on the USA, Europe, and Asia, quality Dell servers, and their own Max Speed Zone technology. Besides, they also guarantee you with uptime and 30 days money back guarantee. So, ASPHostPortal is the best choice in choosing the Best and Affordable ASP.NET Hosting

discountservice-icon-e1421396726386-120x120DiscountService.com.au is based out of three distinct Data Center locations, which operate under the highest industry standards. DiscountService has consistently been able to offer some of the most competitive prices in the hosting industry. They do this by purchasing their equipment up front and utilizing word of mouth advertising. This allows them to run debt free, and saves millions on advertising and marketing. All of these savings are passed down to the consumer, which produces a company that provides cutting edge technology at affordable prices, while still allowing them to be successful and profitable.

DiscountService.com.au prides itself in providing web hosting with a rare combination of unmatched reliability, quality and affordability. DiscountService.com.au's edge is derived through unparalleled company management and a culture of employee driven initiative

hostforlife-icon-e1421832276583-120x120HostForLIFE.eu’s easy to use web hosting solutions have made us one of the leading Windows and ASP.NET Hosting service providers in the European continent for years. They were among the first businesses in the IT sector to offer a fully automated web hosting solution and their continue to lead the market  through the constant development of their web hosting technologies

HostForLIFE.eu team of IT professionals manage your shared hosting plan 24/7 to make sure that your website is  running smoothly and securely. Whether you want to upgrade scripts, web apps or open source software,  their team of experts will be happy to implement the upgrades for you, alleviating the stress of doing  it yourself. Their team will also be able to monitor installations and upgrades to help correct any  issues that could arise with compatibility or on-page functionality

Network security and the security of your server are ASPHostPortal’s top priorities. Their security team is constantly monitoring the entire network for unusual or suspicious behavior so that when it is detected we can address the issue before our network or your server is affected.

Engineers staff Their data center 24 hours a day, 7 days a week, 365 days a year to manage the network infrastructure and oversee top-of-the-line servers that host ASPHostPortal clients’ critical sites and services.

error: Content is protected !!