954,529 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to create one login page in ASP.NET using C#

Hi every one,Could you help me in creating one login page,in which the username and password get validate with the backend db(sql server)And the password is encrypted and stored in db.So I want to know how to encrypt the user inputting password and validate that one against the encryted password in db.?I want the full code...Its an immediate one....!Please help me to create....

Gowrishankar
Newbie Poster
13 posts since Jun 2006
Reputation Points: 10
Solved Threads: 1
 

Sorry.

We do not do your work for you. Please post some code, and we'll help troubleshoot it.

Incidentally, if you search our forums, you'll probably find some examples of an ASP.NET login page.

alc6379
Cookie... That's it
Team Colleague
2,820 posts since Dec 2003
Reputation Points: 186
Solved Threads: 147
 

Sorry.

We do not do your work for you. Please post some code, and we'll help troubleshoot it.

Incidentally, if you search our forums, you'll probably find some examples of an ASP.NET login page.


well, maybe you could me some links on tutorials you know..thanks

crash0verride
Newbie Poster
3 posts since Apr 2007
Reputation Points: 10
Solved Threads: 0
 

microsoft.com has tons of tutorials asp.net 2 and c#

mariocatch
Junior Poster
103 posts since Apr 2007
Reputation Points: 11
Solved Threads: 17
 
kumar.nitesh
Newbie Poster
15 posts since Apr 2007
Reputation Points: 10
Solved Threads: 0
 

You can use Form Authentication mode and give the connection string representing your database.Using form Authentication you can able to send userdata to db verified it and return the msg from database. Just you have to change your config file.

kumar.nitesh
Newbie Poster
15 posts since Apr 2007
Reputation Points: 10
Solved Threads: 0
 

Hi every one,Could you help me in creating one login page,in which the username and password get validate with the backend db(sql server)And the password is encrypted and stored in db.So I want to know how to encrypt the user inputting password and validate that one against the encryted password in db.?I want the full code...Its an immediate one....!Please help me to create....

miracle007
Newbie Poster
3 posts since Oct 2009
Reputation Points: 10
Solved Threads: 1
 
Hi every one,Could you help me in creating one login page,in which the username and password get validate with the backend db(sql server)And the password is encrypted and stored in db.So I want to know how to encrypt the user inputting password and validate that one against the encryted password in db.?I want the full code...Its an immediate one....!Please help me to create....


u design the form in design view by inserting the table with 5 or 6 rows and two columns.then from toolbox in the view sub menu drad and drop lebels,textboxes and buttons and set their property

sawera
Newbie Poster
1 post since Jun 2009
Reputation Points: 9
Solved Threads: 0
 
sumadhuri
Newbie Poster
1 post since Nov 2009
Reputation Points: 10
Solved Threads: 0
 

There was a well written example of a login screen posted on these boards very recently.

As alc6379 mentioned, the policy at Daniweb is to show that you have made an effort before posting your problems. We will gladly offer you guidance and fixes to get your code working, but you need to do the ground work first. Especially with a topic as common as this, there are a hudnred and one tutorials, just put "C# login form" into google and start reading :)

Ryshad
Nearly a Posting Virtuoso
1,307 posts since Aug 2009
Reputation Points: 512
Solved Threads: 246
 

send me sourced code of login page in .net

suresh kumar.k
Newbie Poster
2 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 
reply


at 9949920871

suresh kumar.k
Newbie Poster
2 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

plz tell me the way of creating a registration page in c#....?????

amaninder
Newbie Poster
1 post since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

Please my problem has brought me to the good community of yours. i 've been try to write asp.net /c# code to validate user input 'pin' on the textbox in the sql database. if the pin is exist in the dbs then i delet it from the table it exist and insert it another table. only validation has been giving me sleepless night.
pls even though am new, ijust need the help of brothers. pls somebody help me out. here is the code i have been trying to work on my submit button:
DataTable pinTable = new DataTable();
try
{
SqlConnection connection = null;
string conn = ConfigurationManager.ConnectionStrings["SchooldataConnectionString1"].ConnectionString;
string found = "SELECT * FROM Allpindbs";
connection = new SqlConnection(conn);
connection.Open();
SqlDataAdapter dAdapter = new SqlDataAdapter();
dAdapter.SelectCommand = new SqlCommand(found, connection);
dAdapter.Fill(pinTable);
connection.Close();

}
catch (Exception ERR)
{

throw ERR;
}
foreach (DataRow oRow in pinTable.Rows)
{
PinCode.CompareTo(oRow["Pin"].ToString());
}
if (PinCode.CompareTo("Pin".ToString()) == 0)
{
MessageBox.Show("pin must be deleted");
}
else
{
MessageBox.Show("Invalid pin");
}
}
private void clearControls()
{
this.txtFullName.Text = " ";
this.txtRegNumber.Text = " ";
this.txtPinCode.Text = " ";
this.ddlGender.Text = " ";
this.txtLbl.Text = " ";
this.txtpassword.Text = " ";
}

}

DataTable pinTable = new DataTable();
        try
        {
            SqlConnection connection = null;
            string conn = ConfigurationManager.ConnectionStrings["SchooldataConnectionString1"].ConnectionString;
            string found = "SELECT * FROM Allpindbs";
            connection = new SqlConnection(conn);
            connection.Open();
            SqlDataAdapter dAdapter = new SqlDataAdapter();
            dAdapter.SelectCommand = new SqlCommand(found, connection);
            dAdapter.Fill(pinTable);
            connection.Close();

        }
        catch (Exception ERR)
        {

            throw ERR;
        }
        foreach (DataRow oRow in pinTable.Rows)
        {
            PinCode.CompareTo(oRow["Pin"].ToString());
        }
        if (PinCode.CompareTo("Pin".ToString()) == 0)
        {
            MessageBox.Show("pin must be deleted");
        }
        else
        {
            MessageBox.Show("Invalid pin");
        }
    }
    private void clearControls()
    {
        this.txtFullName.Text = " ";
        this.txtRegNumber.Text = " ";
        this.txtPinCode.Text = " ";
        this.ddlGender.Text = " ";
        this.txtLbl.Text = " ";
        this.txtpassword.Text = "    ";
    }

}
denmarkstan
Junior Poster in Training
59 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
 

Firstly, you are looping through each row but not storing the result of your test anywhere. I would suggest something like:

bool found = false;
foreach(DataRow dr in Table.Rows)
{
    if(dr["column"].ToString() == "somestring")
    {
        found = true; //store result
        break; //exit foreach loop as you no longer need to search remaining items
    }

    if(found)
    {
        //perform action based on result
    }
}


Secondly, you are using the wrong string method. IF you take a look at the msdn reference , you'll find:
Caution!

The CompareTo method was designed primarily for use in sorting or alphabetizing operations. It should not be used when the primary purpose of the method call is to determine whether two strings are equivalent. To determine whether two strings are equivalent, call the Equals method.

Ryshad
Nearly a Posting Virtuoso
1,307 posts since Aug 2009
Reputation Points: 512
Solved Threads: 246
 
You can use Form Authentication mode and give the connection string representing your database.Using form Authentication you can able to send userdata to db verified it and return the msg from database. Just you have to change your config file.


i tell you what i am doing

i have created a table in database that keeps username and passwords but my problem is how that table is made protected because from where i had installed sql server, thats a server and many students can work on the database as it is their subject.
is there some method so that any one can not see my database. is there some password property that could be applied to the sql server database

nareshdwivedi
Newbie Poster
1 post since Sep 2010
Reputation Points: 10
Solved Threads: 0
 

u can use login tool from the login tool box.....

&

also u can do the coding in c sharp.

nidhi18sep
Newbie Poster
4 posts since Jan 2011
Reputation Points: 10
Solved Threads: 0
 

whtr u doing people plz i informed u after some bcoz now i m busy in my project

afjal nathani
Newbie Poster
1 post since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You