Click here to Skip to main content
15,921,941 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I am the begginer for asp.net could you help me for login page in asp.net
Posted

it can be declare globaly

C#
SqlConnection con;
    SqlCommand cmd;
    SqlDataReader dr;
    int flag = 0;
    string s1, s2, uname, upass;

write code on btton click event it shoud be great helpful

 con = new SqlConnection("Data Source=.; Initial Catalog=krishna; Integrated Security =true;");
            con.Open();
            cmd = new SqlCommand("select *from register", con);
            dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                uname = dr[2].ToString();
                upass = dr[3].ToString();

                //if (s1.Equals(uname) && (s2.Equals(upass)))
                if (s1 == uname && s2 == upass)
                {
                    flag = 1;
                    break;

                }

            }
            if (flag == 1)
            {
                Server.Transfer("Welcometest.aspx?uname=+"+s1+""); 
                //Response.Redirect("WelcomeStudent.aspx");

            }
            else
            {
                Label3.Visible = true;
            }


in this code equire database file to match the database and go to the next page
 
Share this answer
 
v2
Comments
Legor 31-Aug-12 4:37am    
This isn't probably much help to a beginner.
Devendra 1988 31-Aug-12 5:43am    
this code for beginer if you are creating login page ....i don't know about you if u have small or middle knowledge you can use this code
First you need tho choose a membership provider. Let's assume you choose SQL based one, that's shipped with the framework. You can read about it here: Using SQL Membership with ASP.NET Application[^]; than you need to follow the steps described here: http://msdn.microsoft.com/en-us/library/ff649314.aspx[^] to configure and use the provider.

Alternatively read this article: http://www.aspfree.com/c/a/.NET/Creating-ASPNET-Login-Web-Pages-and-Basic-Configuration-/[^]
 
Share this answer
 
Comments
Manas Bhardwaj 31-Aug-12 4:01am    
right +5!
Zoltán Zörgő 31-Aug-12 4:49am    
Thank you
Prasad_Kulkarni 31-Aug-12 6:46am    
Good suggestion of Membership, +5
Zoltán Zörgő 31-Aug-12 7:13am    
Thank you
 
Share this answer
 
v2
Comments
Manas Bhardwaj 31-Aug-12 4:01am    
yup +5!
__TR__ 31-Aug-12 4:02am    
Thank you Manas :)
_Amy 31-Aug-12 4:53am    
5'ed. :)
__TR__ 31-Aug-12 5:40am    
Thanks Amit :)
D-Kishore 31-Aug-12 5:41am    
nice 5:)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900