i want login page code using c# and asp

Posted by Radhekrisna under C# on 2/10/2010 | Views : 39384 | Status : [Member] | Replies : 4
hi,
i want to creeate login page in that page user name ,password and login button .
if the person want to login the user id and password retervied from database .
This is my requirement pls send me step by step instructions.




Responses

Posted by: Raja on: 2/10/2010 [Member] Starter

Up
0
Down
Many similar kind of questions have already been asked recently. I would suggest you to search using http://www.dotnetfunda.com/search/SearchForums.aspx page using "login" keyword.

Alternatively go to http://www.dotnetfunda.com/forums/thread1345-login-page-code.aspx page.

Thank you.

Regards,
Raja, USA

Radhekrisna, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Suneel161 on: 2/10/2010 [Member] Starter

Up
0
Down


chek dis code


using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Data.SqlClient;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void loginn_Click(object sender, EventArgs e)
{
validateuser(txtusername.Text.Trim(), txtpassword.Text.Trim());
}
public void validateuser(string user, string pass)
{

string strconnection = "Server=sun ;database=test;uid=sa;pwd=sa;";

SqlConnection sqrconnection = new SqlConnection(strconnection);
String SQLQuery = "SELECT username,password FROM usertable where username='" + txtusername.Text + "' and password='" + txtpassword.Text + "'";
SqlCommand command = new SqlCommand(SQLQuery, sqrconnection);
sqrconnection.Open();
DataTable dt = new DataTable();
SqlDataAdapter ad = new SqlDataAdapter(command);

ad.Fill(dt);
if (dt.Rows.Count > 0)
{
Response.Redirect("Default.aspx");

}

else
{
Response.Write("INVALID Username and Password, Try Again!");

}

sqrconnection.Close();


}




}


Radhekrisna, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Raja on: 2/10/2010 [Member] Starter

Up
0
Down
Hey Suneel,

It would have looked much better if you would pasted the code under CODE block.

Suggest to modify to make it better.

Thanks

Regards,
Raja, USA

Radhekrisna, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bubbly on: 2/10/2010 [Member] Bronze

Up
0
Down
Hello,

Check this link

http://www.c-sharpcorner.com/UploadFile/raj1979/LoginControl07242008104351AM/LoginControl.aspx

++
Thanks & Regards,
Deepika

Radhekrisna, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response