How to make Registration and Login Page in ASP.NET

By
Hi Friends!Today, i am going to make a Custom  Registration and Login Page.This is not a simple web form page.In this Form i have used many concepts.You can easily implement this concept to any where in .NET Application. In this application i have covered all things which is required in various Registration and Login Form in any  website.I am really saying to you,if you run this application on your computer then you will feel how much good it is.You can download this application from bottom and run on your visual studio.There are some controls which i have used in this application.
There are some steps to make this application.Please follow this.
Step 1: First open your visual studio->File->New->website->ASP.NET Empty website->click OK.->Now open Solution Explorer->Add New Item-> Web form-> click Add.
Step 2: Now make a Registration page like this,which is given below.
see it:

Make this Registration Form in following ways:
  • First put ScriptManager on your form.
  • Create UserName-->Now put UpdatePanel-->Now put TextBox in UpdatePanel->Put RequiredFieldValidator.
  • Password--> TextBox-->Now put RequiredFieldValidator.
  • Retype Password-->TextBox-->Now put RequiredFieldValidator.
  • Mobile Number-->TextBox-->Put RegularExpressionValidator &  RequiredFieldValidator
  • Email Id -->TextBox-->Put RegularExpressionValidator and  RequiredFieldValidator.
  • Captcha Image-->To know more here
  • Enter Captcha Image-->TextBox-->Put Label and RequiredFieldValidator.
Now go propeties in every RegularExpressionValidator &  RequiredFieldValidator and set following fields which is given below:
Control To Validate -->Select TextBox which you want to validate. open this application on your visual studio and see all changes.This is more easy for you.
Step 3: Now Add Database(.mdf) on your website.Open Solution Explorer -->Right click on website-->Add New Item-->Sql Server Database-->click Add.

Now if you are facing problem in adding database(.mdf) on Website,please here.
Step 4: Now Double click  on Database.mdf --> Solution Exporer will open-->Right click on Tables -->Add New Table-->Now Enter the column name.
see it:

Step 5: Now double click on Submit Button and write the following code which is given below:

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Drawing;

public partial class _Default : System.Web.UI.Page
{
    protected void TextBox1_TextChanged(object sender, EventArgs e)
    {  
        SqlConnection con = new SqlConnection(@"Data Source=.\;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True;");
        con.Open();
        SqlCommand cmd = new SqlCommand("select*from regform where username='" + TextBox1.Text + "'", con);
        SqlDataReader dr = cmd.ExecuteReader();

        if (dr.Read())
        {
            Label1.Text = "User Name is Already Exist";
            this.Label1.ForeColor = Color.Red;
        }
        else
        {
            Label1.Text = "UserName is Available";
            this.Label1.ForeColor = Color.Red;
        }
        con.Close();
    }
    protected void  Button1_Click(object sender, EventArgs e)
{
    captcha1.ValidateCaptcha(TextBox6.Text.Trim());
    if (captcha1.UserValidated)
    {   //you can use disconnected architecture also,here i have used connected architecture.
        SqlConnection con = new SqlConnection(@"Data Source=.\;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True;");
        con.Open();
       SqlCommand cmd = new SqlCommand("insert into regform values(@a,@b,@c,@d)",con);
        cmd.Parameters.AddWithValue("a", TextBox1.Text);
        cmd.Parameters.AddWithValue("b", TextBox2.Text);
        cmd.Parameters.AddWithValue("c", TextBox4.Text);
        cmd.Parameters.AddWithValue("d", TextBox5.Text);
        cmd.ExecuteNonQuery();
        Session["name"] = TextBox1.Text;
        Response.Redirect("default.aspx");
        con.Close();
    }
    else
    {
 Label2.ForeColor = System.Drawing.Color.Red;
 Label2.Text = "You have Entered InValid Captcha Characters please Enter again";
  }     
 }   
 }

Step 6: Now create a New page and make a Login form which is give below:
see it:
Note->In this application  all (* )represents the Label control.
Step 7: Now Double click on Login Button and write the following codes which is given below:

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Drawing;

public partial class login : System.Web.UI.Page
{
    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(@"Data Source=.\;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True;");
        con.Open();
        SqlCommand cmd = new SqlCommand("select COUNT(*)FROM regform WHERE username='" + TextBox1.Text + "' and password='" + TextBox2.Text + "'");
        cmd.Connection = con;
        int OBJ = Convert.ToInt32(cmd.ExecuteScalar());
        if (OBJ > 0)
        {
            Session["name"] = TextBox1.Text;
            Response.Redirect("default.aspx");
        }
        else
        {
            Label1.Text = "Invalid username or password";
            this.Label1.ForeColor = Color.Red;
        }
    }
    protected void LinkButton2_Click(object sender, EventArgs e)
    {
        Response.Redirect("Registration.aspx");
    }
}

Step 8: Now Create a another page (Default.aspx)which is given below:
see it:

Step 9: Now Double click on Page and write the following codes  on Page load which is given below:

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Label1.Text = Session["name"].ToString();
    }
}

Step 10: Now Run the program(Press F5).
see it:

There are some points to see the Exact output of whole application.
     1. If you are not part of this application then click New User Button.
   see it:
   

     2. When you will Enter UserName then this user name will check from database.if this name is available then it will show User Name is available otherwise show User Name is Already Exist.
  see it:


     3.  when you will Enter Password & ReType Password  Field ,if both Password are not matched then see it:

   
      4. when you will Enter Mobile Number Field ,if Number is Not correct (according to India).you will see following output:
 
 
      5. If you will Enter Email Id Field and Email is not correct format then you will see following error.


     6.when  you will enter wrong Captcha code then you will see following output:

 

     7. When you will enter all fields in Registration page correct then you will see following output:
 
 Step 11: Now you will see Rajesh has  entered Database(.mdf).
see student table:


  
   Step 12: Now you can directly Login  with correct Login Name and Password,which is present in Database(.mdf).
see it:

see output:-

Step 13 : You can add Change Password page in this page from  here

Step 14 : You can add Forget password codes in this page from here

Step 15 : You can add send email service in this page from here

Step 16 : You can build 3 Tier Registration and Login page from here.

Step 17 : You can create existing asp.net registration and login page esaily from here.

Step 18 : You can use cookie concepts in this page from here.

Step 19 : You can use caching concepts in this page from here.

Step 20 : You can create secure registration and login page with hashing in asp.net here.

Note- If you want to run this application on your system directly, without any changes then follow first two steps(1 to 2)  and other four steps(3 to 6),you can add extra features in your application which are given below:
  1. First download this application form bottom and open this application to your visual studio 2010.
  2. Now go Tools -->Options -->Database Tools -->Data connections -->Remove Sql Server Instance Name(blank for default) from right hand side-->click OK.
  3. If you want ,you can implement Form Based authentication in this form for security purpose.
  4. You can use different connection strings for your registration and loin page also from here. Such as store procedure,connected architecture,disconnected architecture parameterized connection etc.It will provide full security to your asp.net application.
  5. This registration page is full secure,i have putted security codes also.
For More:-
  1. How to build Real Form Filling Application like IBPS  
  2. Learn More .NET Interview Questions and Answers for Job seekers
  3. Create a Setup File
  4. Take Print receipt in Windows Form Application
  5.  File Handling Real Application
  6.  E-Post System Project
  7. Overview of C#
  8. Call by value and call by reference
  9. How to implement all Web Form controls in asp.net
  10. Data List Real Application
  11. Repeater control Real application
  12. How to use session in asp.net application
  13. How to use Navigation control in asp.net
  14. How to implement web services in asp.net application
  15. How to use WCF Services in asp.net application.
  16. Create captcha image without dll file in asp.net
  17. How to create setup file with database
  18. How to Create photo gallery of your friends like facebook and google+
  19. How to build Your own window media player easily
  20. How to host your WCF services on your local computer and use it from other computers also
  21. How to use secure login page in asp.net with example
  22. How to Add and verify Captcha image in 3 tier architecture in asp.net
  23. How to use virtual keyboard in asp.net for security purpose
  24. How to implement hashing concepts in asp.net
  25. Learn complete .Net Interview Questions and answers for job seekers
 I hope this helpful for you.
Please share this page if this is helpful for you.
      Download Whole Attached file
            Download

127 comments:

  1. hi...
    really good article but can u tell me i want to place another button and change/refresh image on click how to do it???

    thnx in advance

    ReplyDelete
    Replies
    1. Hi...this very good articles that is use full fore me and others thanks but I need more things fore you so how to add ore pages and how to re direct it?

      Delete
  2. @Vivek sharma
    bro.. use AdRotator control on page.visit:
    http://www.msdotnet.co.in/2013/07/web-forms-controls-in-aspnetii.html

    ReplyDelete
  3. forget link code is not avail

    ReplyDelete
  4. @Akash Raina I have checked ,it is working........
    Try again.....

    ReplyDelete
  5. thank you very much Ramashanker Verma this has really helped me for my final project as i am preparing the registration web

    ReplyDelete
  6. what about forgot password code ?

    ReplyDelete
    Replies
    1. i will explain it in separate tutorial........wait

      Delete
  7. whenever i click on submit or login button i am shown this
    can u please help?
    Server Error in '/WebSite4' Application.
    A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

    Source Error:


    Line 15: {
    Line 16: SqlConnection con = new SqlConnection(@"Data Source=.\;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True;");
    Line 17: con.Open();
    Line 18: SqlCommand cmd = new SqlCommand("select COUNT(*)FROM regform WHERE username='" + TextBox1.Text + "' and password='" + TextBox2.Text + "'");
    Line 19: cmd.Connection = con;

    ReplyDelete
    Replies
    1. @Raer ,your visual studio connection setttings and sql server instance may not same.please follow this tutorials from start to end and implement it on your sql server and visual studio as shown in tutorial. you will definitely solve your problem. visit:-
      http://www.msdotnet.co.in/2013/04/how-to-solve-problem-to-add-sql.html

      Delete
  8. the problem is in con.open()
    Also when i try to view default.aspx in browser it show this
    Object reference not set to an instance of an object.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

    Source Error:


    Line 8: protected void Page_Load(object sender, EventArgs e)
    Line 9: {
    Line 10: Label1.Text = Session["name"].ToString();
    Line 11: }
    Line 12: }


    Source File: c:\Users\jc\Documents\Visual Studio 2010\WebSites\WebSite4\Default.aspx.cs Line: 10



    with the problem being in the label1.text line
    Pls help

    ReplyDelete
    Replies
    1. @Raer, first store the session value in session object on first page as
      session["name"]=TextBox1.Text; after that show the session value on the second page as Label1.Text = Session["name"].ToString(); .You can not open the second page as a startup page first.it will give error.so make "set as startup page" first web form .
      more knowledge about session visit:
      http://www.msdotnet.co.in/2013/10/how-to-use-session-state-in-aspnet.html

      Delete
    2. Amazing and useful one ... i really support u and i will refer the students

      Delete
    3. i want login with smaleest vaue in database
      for supose
      ser value
      1 15
      2 12
      3 10
      i want login smalll value in vaue colum

      Delete
    4. SEND CODING IN MY ID ............gautammaharaj1@gmail.com

      Delete
  9. plz help me out m getting this kind of error
    Unable to open the physical file "C:\Users\PRIYANKA\Documents\Visual Studio 2010\WebSites\LOGIN AND USER REGISTRATION FORM\App_Data\Database.mdf". Operating system error 32: "32(The process cannot access the file because it is being used by another process.)".
    An attempt to attach an auto-named database for file C:\Users\PRIYANKA\Documents\Visual Studio 2010\WebSites\LOGIN AND USER REGISTRATION

    ReplyDelete
    Replies
    1. hello priyanka copy all code for your login and regestration form and new site create in paste code and check the your error...oterwise set the path of storage file......

      Delete
  10. How to create a web services?

    ReplyDelete
    Replies
    1. 1.open a empty website
      2.add new item
      3.select web service
      4.than write down
      [webmethod]
      public int add(int x + int y)
      {
      return(x+y);
      }
      5.than run ..........
      same as multiply and sub....

      Delete
  11. Its really help full thanks bro.........

    ReplyDelete
  12. @priya Jadhav sorry for late reply.This error is coming due not open Database.mdf file.To solve this problem see this post:-http://www.msdotnet.co.in/2013/04/how-to-solve-problem-to-add-sql.html

    ReplyDelete
  13. @Sushma Rani i will discuss this our coming tutorials wait.........

    ReplyDelete
  14. give me code for forgot page plz.i really need it...........

    ReplyDelete
    Replies
    1. visit:- http://www.msdotnet.co.in/2013/11/how-to-send-forget-password-is-aspnet.html

      Delete
  15. HI, select count (*) from Table_name command is always fetch the record and redirect to the specified page.

    ReplyDelete
    Replies
    1. if you want to stay same page then delete below code
      Response.Redirect("default.aspx");

      Delete
  16. in login page it shows below type of error..
    this is code
    int OBJ = Convert.ToInt32(cmd.ExecuteScalar());
    error is : Input string was not in a correct format.

    ReplyDelete
  17. Hi Dear Friend.


    I would like to make customized outlook web access page.

    But I don't. So please help me.

    ReplyDelete
  18. i m facing this problem plz help me
    The system cannot find the file specified
    Line 19: SqlConnection con = new SqlConnection(@"Data Source=.\;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True;");
    Line 20: con.Open();
    Line 21: SqlCommand cmd = new SqlCommand("select COUNT(*)FROM regform WHERE username='" + TextBox1.Text + "' and password='" + TextBox2.Text + "'");
    Line 22: cmd.Connection = con;

    ReplyDelete
  19. you are facing connection problem.read below link;-
    http://www.msdotnet.co.in/2013/04/how-to-solve-problem-to-add-sql.html

    ReplyDelete
  20. mind bloing..............
    awasaaaaaaaammmmmmmmmmmmm

    ReplyDelete
  21. how the registration page more attractive?that is stylish textboxes,button etc.

    ReplyDelete
  22. HI HOW TO UPLOAD An photo and display in same from n in database

    ReplyDelete
  23. i have download ur project and try to open there no file with extension .slm. but i have open each file one after the other and when i ty to run it is showing me to attachment some what is that ?
    yes i am new to asp.net and want to learn from you please help me..............

    ReplyDelete
  24. Hi Mr. Ramashanker Verma

    This work is so very helpful.
    How can I verify my registration using the email id i used for registration.. .do you have a code for it (email verification) ? Thank you for the help.

    ReplyDelete
  25. do you also able to generate auto suggest username like in registation yahoo.com .. may you help me pls. thank you i need my school project

    ReplyDelete
  26. hello sir,
    how are you?
    how to add profile image in profile and how to set http address like in facebook.com and facebook.com/zakee.malik.. please help me

    ReplyDelete
  27. hello sir , i have completed all coding and design for registration form , but its does not work , its application run , does not redirect to another page and user details like user name, mob num, email id did not insert into table. i dont know what is my mistake ,
    i want to implement my project ,,,,, i need ur comment..

    ReplyDelete
    Replies
    1. hi kalpana,what error is showing,when you click button,then i can tell you what is actual problem in your application.........

      Delete
    2. when i click submit btn , does nt show any error ,its simply on same page olny.. data did nt insert into table and did nt direct

      Delete
  28. Hi plz help me.. I want to create login page where i enter a name as username then login... when I enter a login then it can display me a homepage... and in homepage there will b another button logout... plz tell me the code.... as soon as possible(using session)

    ReplyDelete
    Replies
    1. sorry for late reply,i have not seen you comment.
      session["variable_name1"]=null;
      session["variable_name2"]=null;
      response.redirect("home.aspx");
      Or
      session.removeall();
      response.redirect("home.aspx");

      Delete
  29. hi i followed all proceduer as you gave in add capcha image but i got Error like "The type or namespace name 'MSCaptcha' could not be found in the global namespace (are you missing an assembly reference?)".So please can you give mi solution on this?

    ReplyDelete
  30. Hi kalpana ,your handler is not working correctly.first download the application -->open your visual studio 2010-->only change connection strings otherwise read http://www.msdotnet.co.in/2013/04/how-to-solve-problem-to-add-sql.html
    this then you will not have to change connection strings.

    ReplyDelete
  31. Hi..Sir.
    Please tell me that how to use filter for data searching without database. Actually i have to call API.

    ReplyDelete
  32. hello sir,
    i've followed all the code you posted
    but i got some problem on the checking of the username
    it doesn't show any error in checking the username but the label doesn't automatically show the text which notify that the username is available. I've put the textbox in the update panel though
    can u give me some advice? thx

    ReplyDelete
    Replies
    1. hi Alvin , go properties set AutoPostBack = True.then will work .........

      Delete
  33. thank you so much.......................

    ReplyDelete
  34. How to use ms access database in this program????

    ReplyDelete
  35. Y don't u reply n my comment???

    ReplyDelete
  36. I want to connect my login page to Sql database ...How can i do that ?and more how can i know if i enter some values in login page or registration page can we know whether it is storing in our database or not? how can we know that/ will u please explain me

    ReplyDelete
    Replies
    1. hi shalini !
      1.) in above post i have used Database.mdf file for login. you can login with sql database or other database by providing connection strings.i have mentioned different connection strings with database,you can see from below link.
      http://www.msdotnet.co.in/2013/12/how-to-use-different-connection-strings.html
      2.) If you want check whether data is inserted in database or not .open solution explorer-->open Database.mdf file --> Tables--> right click on your tables name ---> Show Table Data.you can see data is inserted or not.other things if data is not inserted in table then it will give error.
      3.) if want to attached Database.mdf or .sdf file in your sql server then read below links.
      http://www.msdotnet.co.in/2014/03/how-to-attached-mdf-or-sdf-file-in-sql.html

      first read above links carefully ,if any other problem ask frequently......

      Delete
  37. hello.what is the use of update panel and script manager??????

    ReplyDelete
    Replies
    1. Read below link:
      http://www.msdotnet.co.in/search/label/Ajax

      Delete
    2. thanks dude.............

      Delete
  38. i am getting error.please help
    the page says: Server Error '/' Application
    Webforms UnobstructiveValidationMode requires a ScriptResourseMapping For 'jquery'.Please add a ScriptResourseMapping names jquery(case-sensitive).

    ReplyDelete
  39. Hi sir i run that program successfully but when i enter the detail on registration page then the database connection error will show the visual studio open and cursor on open con and that error come on the mobile entry

    ReplyDelete
    Replies
    1. Go step 5-->check Text Box change connection string codes-->this connection strings are showing errors-->correct it then it will work....

      Delete
  40. Hi sir i successfully run that registration page but when i entry n registration page so the database error come when i entry in the mobile no text box that time visual studio show the cursor on con.Open(); command so please help me how i resolve that problem

    ReplyDelete
    Replies
    1. hi Vikash, your connection string are not working properly.first correct it by reading the above tutorials carefully.

      Delete
  41. can we give primary key with identity??

    ReplyDelete
  42. hi komal ! Yes ,you can set a primary key in your database column...

    ReplyDelete
  43. Hi Verma,

    I want to create a registration page with first name,last name,cellphone number and prefered contact whould be email or text.
    Please help me in the coding.
    If user click the SUBMIT BUTTON.
    The details should store in sql.
    Please help me .

    Thank you,
    Sowjanya.

    ReplyDelete
    Replies
    1. hi sowjanya ! In above tutorial ,you can store all values in sql database by click submit button..Here i have used .mdf database which is a part of sql database.you can store your values in separated database also if you want. you can follow below link for connection string in separate sql database .
      http://www.msdotnet.co.in/2013/12/how-to-use-different-connection-strings.html

      Delete
  44. in login page i give the link button to change a password... so what is the code for change password in asp.net.. using C#

    ReplyDelete
  45. Hi Varunda !
    Apply this concepts:-
    1 ) first fetch password value from you sql table.
    2.) If password is present in database then update new password value on that column (password) by sql command.
    i will add this concepts in this login page as soon as possible.

    ReplyDelete
  46. i have also problem in to create a login page with different user admin & other user. and i want to give few right to user & admin so how can i do .

    ReplyDelete
  47. hI Vrunda ! use form based authentication for this. You can specify each admin name and password in this section.i have mentioned this link on this form.

    ReplyDelete
    Replies
    1. plz give me link of the below question...

      Delete
    2. read below link:-
      http://www.msdotnet.co.in/2014/02/how-to-implement-form-based.html

      Delete
  48. hello sir, i have one more to create crystal report in asp.net ...so i want to send my form & table for explanation so how can it possibal..?

    ReplyDelete
    Replies
    1. i have not written any post on crystal report.i will post soon.so please refer it from other places.....

      Delete
  49. Hello... I want to attach database in SQL server management.. When I click on databases then right click --> Attach --> Add --> choose file --> Then OK....... I got the error msg " attach database failed for server 'RUMAISAKHAN-PC'. (Microsoft.sqlServer.Smo)..... what I will do now...... Please reply ASAP..

    ReplyDelete
  50. Replies
    1. hi Rumaisa ! first open your sql server in Administrative mode.Read below links for this:-
      http://www.msdotnet.co.in/2014/03/how-to-attached-mdf-or-sdf-file-in-sql.html

      Delete
  51. helo sir,,,,,,,,
    can you help me in mvc????
    to create login page with sql sever

    ReplyDelete
  52. Hi Verma,
    i have already created a login n registration page....nw i wanted to create a Administrator page so that Admin can be able to change the roles of the users ...without using the roles management... can u plz help me out sir ...

    ReplyDelete
    Replies
    1. hi nandini ! you have to create custom roles in web.config file.Read below post and follow step 3 .It will help you definitely.......
      http://www.codeproject.com/Articles/22503/Custom-Membership-Role-Providers-Website-administr

      Delete
  53. hi, its good. I want to send E-mail by using my asp page, please help me.

    ReplyDelete
    Replies
    1. hi Admin ! Read Step 15 here link.it wil be helpful to send email service in asp.net application

      Delete
  54. Hello Sir,
    I am creating an online examination website which is to be hosted on web.Is it necessary to use post/get methods to store data in database???

    ReplyDelete
  55. Hi shah ! Without get or post method how can you add data in your database.Yes ,it is necessary to submit data from one place to another place in HTML.
    Read below link for more information about get and post methods:-
    http://www.w3schools.com/aspnet/aspnet_forms.asp

    ReplyDelete
  56. Hi Sir ,
    I didn't type any value in the TextBox1 yet my label message or label1 Status is already shown, why is that so ? please help me.

    ReplyDelete
    Replies
    1. Hi MICHELE , What message is showing in your label control.if want to hide your Label control on the page then go properties of Your label control --> Set Text = * if you remove all text of label control then label1 message will be shown on your page.So don't leave blank of your Label Text properties.If any other problem then specify it..

      Delete
  57. Is it possible to add roles for login pages? if yes , how to do it? which means after the user have entered the correct username and password , if the user is admin , they will be redirected to admin pages .. If the user is a teacher , they redirected to teacher pages ?please help me.. its for my school project >.<

    ReplyDelete
    Replies
    1. yes.... you can use simple method.Use a dropdownlist in you login page with three fields student,teacher,administrator. use if and else conditions and solve your problems.it is very simple method.

      Delete
    2. Thanks ^^ i fixed the role :D

      Delete
  58. It is still showing the label message like "User ID is available" but i didn't type anything in user id textbox. I have set the text = * for label control. Please help me...
    protected void Page_Load(object sender, EventArgs e)
    {
    SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MajorProjectConnectionString"].ConnectionString);
    conn.Open();
    SqlCommand cmd = new SqlCommand("select*from [user] where userid='" + TextBox1.Text + "'", conn);
    SqlDataReader dr = cmd.ExecuteReader();

    if (dr.Read())
    {
    Label2.Text = "User ID is Already Exist";

    }
    else
    {
    Label2.Text = "User ID is Available";

    }
    conn.Close();

    ReplyDelete
    Replies
    1. hi ANN, Your database contains a blank entry that's why this message is showing.Remove blank entry in your database then it will be solved......

      Delete
    2. This comment has been removed by the author.

      Delete
  59. Very easy to understand, thanks for teaching us dude!

    ReplyDelete
  60. A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

    This is what i get when i run my code That too this exception occurs in con.Open();

    Help me with this as soon as possible

    ReplyDelete
  61. Thanks and itz working fine for me!!

    ReplyDelete
  62. Hi.. The ExecuteScalar() method is checking only the 1st row..
    In debugging mode.. Value of obj=1 for 1st entry in the DB.. For rest of the entries obj=0... How to overcome this problem..
    Thanks.

    ReplyDelete
  63. Hi Sir when I run this program iam getting Error
    "The user instance login flag is not supported on this version of SQL Server. The connection will be closed
    please tell me how to fix this error

    ReplyDelete
    Replies
    1. hi Rupesh,
      Read below forum for this error.
      http://forums.asp.net/t/913172.aspx?Error+Message+The+user+instance+login+flag+is+not+supported+on+this+version+of+SQL+Server+The+connection+will+be+closed

      Delete
  64. Hi

    Very nice example one thing is I confused that What is use of scriptmanger and updatepanel here so please explain it

    ReplyDelete
  65. Read below post,,,,
    http://www.msdotnet.co.in/search/label/Ajax

    ReplyDelete
  66. whenever i click on submit or login button i am shown this
    can u please help?
    Server Error in '/WebSite4' Application.
    A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

    Source Error:


    Line 15: {
    Line 16: SqlConnection con = new SqlConnection(@"Data Source=.\;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True;");
    Line 17: con.Open();
    Line 18: SqlCommand cmd = new SqlCommand("select COUNT(*)FROM regform WHERE username='" + TextBox1.Text + "' and password='" + TextBox2.Text + "'");
    Line 19: cmd.Connection = con;

    ReplyDelete
    Replies
    1. Check your Data Source Name in sql server...
      visit below link to solve this problem..
      http://www.msdotnet.co.in/2013/04/how-to-solve-problem-to-add-sql.html

      Delete
    2. sir can u please help me how to create job application in asp.net using c# and the fileupload,qualification must be master and they should be in dropdown fileds must be manidatory can u please uplaaod this video

      Delete
  67. hello ,Ramsankar verma will it work in visualst

    udio2013.i m facing error ...

    ReplyDelete
  68. Thank you sir, this is very helpful for me
    I want to know more about asp.net from you, But how can it possible ?

    ReplyDelete
    Replies
    1. Hi Nawaraj, Read every post on this website and implement each post on your visual studio.if any problem you can ask me.....i will helpful...

      Delete
    2. hi sir, my name is hailemariam, i live in Ethiopia. I wanna to create sign language using C# language. so, can you help me a simple code to create sign language? please hep me!

      Delete
  69. Hello sir, I was going through your article... Its great but I just wanted to know how to display some content only for logged in users and how to avoid the non-users from watching it... Thanks and regards.

    ReplyDelete
  70. Where I can download the whole code

    ReplyDelete
  71. Hi...can u help me to solve this error
    i created two pages frm_category and frm_investment ,in which frm_category has category,name and address and frm_investment contains date,category,name,investment,previous balance and net amount
    i did coding for frm_category and is executed but in frm_investment a syntax error occured that i couldnt correct
    please help me to solve this.
    if I run this ,a "category" is selected corresponding name should shown in drop down list of "name" .Upto this is done well
    I need your help for the following things:

    1.the selected category member's name is shown and the previous balance should be displayed in the textbox as "0"
    2. If i add investment as "200" then net amount is displayed as 200 (previous balance+investment)
    3.again i run the frm_investment i select another date, and select the same category and corresponding name which i selected in step 1 then the previous balance should be displayed as "200".
    4. Again i add investment "300" the net amount now is 500

    here is the code of frm_investment done by me

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data;
    using System.Data.SqlClient;

    public partial class frmInvestment : System.Web.UI.Page
    {
    SqlConnection con = new SqlConnection("Data Source=(local);Initial Catalog=category;Integrated Security=True");
    protected void Page_Load(object sender, EventArgs e)
    {
    if (!IsPostBack)
    {
    con.Open();
    SqlCommand cmd = new SqlCommand("select * from tbl_category",con);
    SqlDataReader dr = cmd.ExecuteReader();
    while (dr.Read())
    {
    DrpCategory.Items.Add(dr["category"].ToString());

    }
    dr.Close();
    con.Close();

    }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
    con.Open();
    SqlCommand cmd = new SqlCommand("insert into tbl_investment values ('"+txtDate.Text+"','"+ DrpCategory.Text +"','"+DrpName.Text+"','"+txtInv.Text+"','"+txtPrev.Text+"','"+txtNet.Text+"')", con);

    cmd.ExecuteNonQuery();
    con.Close();
    }
    protected void DrpCategory_SelectedIndexChanged(object sender, EventArgs e)
    {
    con.Open();
    SqlCommand cmd = new SqlCommand("select * from tbl_category where category='" + DrpCategory.Text + "'", con);
    SqlDataReader dr = cmd.ExecuteReader();
    DrpName.Items.Clear();
    DrpName.Items.Add("select");

    if (dr.Read())
    {
    DrpName.Items.Add (dr["name"].ToString());
    }
    dr.Close();
    con.Close();
    }
    protected void DrpName_SelectedIndexChanged(object sender, EventArgs e)
    {
    con.Open();
    SqlCommand cmd = new SqlCommand("select * from tbl_investment where name='" + DrpName.Text + "'", con);
    SqlDataReader dr = cmd.ExecuteReader();

    do
    {
    txtPrev.Text = dr["Net amount"].ToString();
    }

    while (dr.Read());
    {

    }

    txtPrev.Text = "0";

    dr.Close();


    con.Close();




    }
    protected void txtInv_TextChanged(object sender, EventArgs e)
    {

    txtNet.Text=Convert.ToString(Convert.ToInt32(txtPrev.Text)+Convert.ToInt32(txtInv.Text));


    }
    }

    ReplyDelete
    Replies
    1. Hi Mohsina m,
      Your variables are taking garbage value,So you have to initialize every variable like txtPrev.Text=null and txtInv.Text=null, if you are doing large project,so you have to initialize every variable either null or 0, if it is taking string put it null at declaration time, if it is taking integer put it 0 at declaration time. I hope this is helpful to solve your problem,if any other problem ask again...

      Delete
  72. Hi..I am new to ASP.net and I followed your login and registration, facing the below error. Please help me.


    Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

    Parser Error Message: 'projectregister.default' is not allowed here because it does not extend class 'System.Web.UI.Page'.

    ReplyDelete
  73. How to encrypt the password of the user?

    ReplyDelete
    Replies
    1. You should not encrypt password. Always do hashing for password.
      Here is code to hash password.

      public static byte[] HashPassword(string password)
      {
      var provider = new SHA1CryptoServiceProvider();
      var encoding = new UnicodeEncoding();
      return provider.ComputeHash(encoding.GetBytes(password));
      }

      Delete
  74. good thank you . how I can doing the same login with c# windows application , please

    ReplyDelete
  75. very good thank you . please I need the same login in c# windows application

    ReplyDelete
  76. Thanks for sharing this Mr. Ramashankar I am using bulk sms asp.net api for bulk sms.Is it good to send bulk sms?

    ReplyDelete
  77. Thanks for sharing this valuable content
    Regards
    Bulk SMS PLANS

    ReplyDelete
  78. Many thanks for sharing such incredible knowledge. It's really good for your Website.
    The info on your website inspires me greatly. This website I'm bookmarked. Maintain it and thanks again.
    I'm really impressed with your writing skills, as smart as the structure of your weblog.

    Output Portal Crack

    ReplyDelete

Powered by Blogger.