Tweet
SIGN UP
MEMBER LOGIN:
TECHNOLOGIES
.NET 4.5
.NET Remoting in C#
Active Directory C#
ADO.NET in C#
AJAX in C#
Algorithms in C#
Android Programming
Articles C#
ASP, JavaScript, CSS
ASP.NET Controls in C#
ASP.NET MVC with C#
ASP.NET Programming
BizTalk Server
C# Assemblies
C# Language
C# Tutorials
C, C++, MFC
Career Advice
Chapters
Cloud Computing
COBOL.NET
Coding Best Practices
COM Interop
Compact Framework
Cryptography C#
Crystal Reports C#
Current Affairs
Custom Controls C#
Databases & DBA
Deployment
Design & Architecture
DirectX C#
Enterprise Development
Error Zone
Exception Handling C#
Expression Studio
F#
Files, Directories in C#
Financial Applications
Games Programming C#
GDI+ & Graphics
Hardware
How do I
HTML 5
Internet & Web
iPhone/iPad
Java
Java and .NET
JQuery
JSP
Leadership
Learn .NET
LINQ with C#
Metro Style Apps in C#
Mobile & Embedded
MonoDevelop
MSMQ in C#
Multithreading in C#
Networking
Office Development
OOP/OOD
Operating Systems
PHP
Printing in C#
Products
Project Management
Reports using C#
Robotics & Hardware
Security in .NET
SharePoint
Silverlight with C#
Smart Devices
Speech in C#
SQL
SQL Server 2012
String in C#
Team Foundation & VSS
Testing
Visual Basic .NET
Visual C#
Visual Studio .NET
Visual Studio 11
Visual Studio 2010
VS LightSwitch 2011
WCF with C#
Web Forms C#
Web Services in C#
WebForms Controls
Windows 8 in C#
Windows Controls C#
Windows Forms C#
Windows Phone in C#
Windows PowerShell
Windows Services in C#
Workflow Foundation in C#
WPF with C#
XAML with C#
XML in C#
XNA with C#
FORUMS
BLOGS
VIDEOS
INTERVIEWS
CERTIFICATIONS
DOWNLOADS
BOOKS
LINKS
NEWS
Learn .NET in 60 days – Part 1 (13 Labs)
Learn MVC (Model view controller) Step by Step ...
Learn C# Corner - Home
Using Border Radius and Gradients in CSS3: Part I
Learn C# Corner - Footer
Learn .NET and C# in 60 Days Lab13(Day 5): - C ...
iPhone 5 First Look
Samsung Galaxy Note Review
WCF - Authentication and Authorization in Ente ...
How to write a good article on C# Corner
Blog
Easy Login using ASP.NET
Posted by
Mohammad Mirshahi
in
Blogs
|
ASP.NET Controls in C#
on
Nov 29, 2011
Here is sample code that uses a database for easy login.
Tweet
722
0
0
Download Files:
EasyLogin.zip
This sample is an ASP.NET Easy login control.
Before runing program you should attach current database in App_Data to your SQL Server.
Here is the try file stream for using manual cookie.
Notic !
if (File.Exists(pah) == true)
{
string str1, str2;
string connection = @"Data Source=mirshahi;Initial Catalog=addressbook;Integrated Security=True";
con = new SqlConnection(connection);
cmd.CommandText = "select * from Login";
cmd.Connection = con;
con.Open();
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
while (dr.Read())
{
str1 = dr.GetString(1);
str2 = dr.GetString(2);
////////////////////////
StreamReader sr = new StreamReader(pah);
string us = sr.ReadLine();
string ps = sr.ReadLine();
if (str1.Equals(us) == true && str2.Equals(ps) == true)
{
l1.Text = "Wellcome !You Are Login...";
Login1.UserName = us;
Login1.FindControl("LoginButton").Visible = false;
sr.Close();
}
else if (str1.Equals(us) == false && str2.Equals(ps) == false)
{
l1.Text = "You Are Log Out,Please Connect...!";
}
}
con.Close();
}
else
{
//l1.Text = "You Are Log Out !";
Login1.FindControl("LoginButton").Visible = true;
string str1, str2, stu, stp;
string connection = @"Data Source=mirshahi;Initial Catalog=addressbook;Integrated Security=True";
con = new SqlConnection(connection);
cmd.CommandText = "select * from Login";
cmd.Connection = con;
con.Open();
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
try
{
while (dr.Read())
{
str1 = dr.GetString(1);
str2 = dr.GetString(2);
////////////////////////
stu = Login1.UserName;
stp = Login1.Password;
stu.Trim(); stp.Trim(); str1.Trim(); str2.Trim();
if (stu.Equals(str1) == true && stp.Equals(str2) == true)
{
Login1.FailureText = l1.Text;
StreamWriter sw = File.CreateText(pah);
sw.WriteLine(str1);
sw.WriteLine(str2);
sw.Close();
con.Close();
Response.Redirect("enter.aspx");
check1();
if (stu.Equals(str1) == false && stp.Equals(str2) == false)
Login1.FailureText = l1.Text;
check1();
}
} check1();
}
catch (Exception)
{
}
Checking my manual cookie of file stream when loged in.
ENJOY IT...
DOWNLOAF FILE ANOTHE WEB :
http://mfc-project.blogfa.com/post-20.aspx
OR :
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=7409&lngWId=10
share this blog :
Captcha Code using ASP.NET
Binding in an ASP.NET DropDownList
Related Blogs
Upload Large Files in SQL in an ASP.NET web application:
Dropdown Menu Code Snippet ASP.NET
File Upload Control in ASP.NET
Showing CheckBox as a list
Benefits of ASP.Net Controls
Get Multiple selected Items from Listbox in asp.net
post comment
Sponsored by
Become a Sponsor
More Blogs from this Blogger
Gmail Sender
Encrypt and Decrypt
Find Hidden Objects
Find Hidden Objects
Easy Login using ASP.NET
Word Translator in C#
Difference between two Photos - Game
Anti Virus Remover for Kernel.exe
Ball and Break Game in C#
Easy Encrypt and Decrypt Zip
View All
Latest Blogs
WebPart Collector or WebPart Finder
Free Ride is Over for Desktop Developers in Visual Studio 11
DotNet developers most used application/tools launching through 'Run'
80-inch Windows 8 Tablet
Data encapsulation
Option to access the Column Names in Data table
Open multiple windows in browser startup. (Multiple homepages option)
I'm Sorry
const and readonly
Address, Binding and Contract in WCF
View All
Sponsored by
Become a Sponsor