Sei sulla pagina 1di 6

3/28/12

Total Online Users: 12231

Login Control in ASP.NET 3.5


How to post a Blog?

Home | Forums | Videos | Advertise | Certifications | Downloads | Blogs | Interviews | Jobs | Beginners | Training | Consulting Search : Home Learn .NET Login Control in ASP.NET 3.5 Go

S bmi an Ar icle

Hi! saurabh Logout My Account My Messages (0) Jump to Technology Website Sponsored b

Advanced Search

Login Control in ASP.NET 3.5


B Raj Kumar Jul 28, 2008
step tutorial, I am going to discuss the Login control available in ASP.NET 3.5. In this step b

Print Email to a friend

Post a comment Bookmark

Similar Articles Author's other articles

Do

nload Files:

LoginControl. ip

The ASP.NET login controls provide a robust login solution for ASP.NET Web applications without requiring programming. By default, login controls integrate with ASP.NET membership and forms authentication to help automate user authentication for a Web site. It provides you with a ready-to-use user interface that queries the user name and password from the user and offers a Log In button for login. It validate user credentials against the membership API and encapsulating the basic froms authentication functionality like redirecting back to the original requested page in a restricted area of you application after the successful login. The Login control displays a user interface for user authentication. The Login control contains text boxes for the user name and password and a check box that allows users to indicate whether they want the server to store their identity using ASP.NET membership and automatically be authenticated the next time they visit the site. The Login control has properties for customized display, for customized messages, and for links to other pages where users can change their password or recover a forgotten password. The Login control can be used as a standalone control on a main or home page, or you can use it on a dedicated login page. If you use the Login control with ASP.NET membership, you do not need to write code to perform authentication. However, if you want to create your own authentication logic, you can handle the Login control's Authenticate event and add custom authentication code. Note - Login controls might not function correctly if the Method of the ASP.NET Web page is changed from POST (the default) to GET. Start Microsoft Visual Studio 200 Create a new ASP.NET WebSite, Like this:

www.c-sharpcorner.com/uploadfile/raj1979/login-control-in-asp-net-3-5/?login=true&user=sabh007@

1/11

3/28/12

Login Control in ASP.NET 3.5

Become a Sponsor Resources About Us ASP.NET Hosting Authors Book Chapters Book Reviews C# Consulting C# Training Downloads Media Kit News & Events Prizes Product Reviews Resources Tips Tools User Groups Our Network .NET Heaven C# Corner DbTalks Interview Corner Longhorn Corner Mindcracker VB.NET Heaven

www.c-sharpcorner.com/uploadfile/raj1979/login-control-in-asp-net-3-5/?login=true&user=sabh007@

2/11

3/28/12

Login Control in ASP.NET 3.5

Drang and drop Login control on page from ToolBox.

www.c-sharpcorner.com/uploadfile/raj1979/login-control-in-asp-net-3-5/?login=true&user=sabh007@

3/11

3/28/12

Login Control in ASP.NET 3.5

Figure .

Whenever user hits the Log In button, the control automatically validates the user name and password using the me and then calls FormAuthentication.redirectFromLoginPage() if the validation was successful. All options on the UI of control to these methods. For Example, if you click the "Remember me next time" check box, it passes the value true RedirectFromLoginPage() method. Therefore, the FormAuthenticateModule creates a persistent cookie. There are three Login Tasks by default.

Auto Format - you can select default schemes. Convert To Template - You can edit content of Login Control. Administer Website - You can configure Web Site Administration Tools, Like Security, Application, Provider.

Figure .
<omi=fr1 rnt"evr> fr d"om" ua=sre" <i> dv <s:oi I=Lgn"rnt"evr BcClr"FFD"BreClr"CC9"BreSye apLgn D"oi1 ua=sre" akoo=#77E odroo=#CC9 odrtl Nms"edn"Fn-ie"0t> ae=Vraa otSz=1p" <ilTxSyeBcClr"666"Fn-od"re FrClr"FFF"/ Tteettl akoo=#B9B otBl=Tu" oeoo=#FFF > <apLgn /s:oi> <dv /i> <fr> /om

You can change styles of LoginControl using css too, Like this:
.oiCnrl Lgnoto { bcgon-oo:FFD; akrudclr#77E bre-oo:CC9; odrclr#CC9 bre-tl:oi; odrsyesld bre-it:p; odrwdh1x fn-aiyVraa otfml:edn; fn-ie1p; otsz:0x Adnwapycst cnrl n o pl s o oto: <tlxls"tp/www.r/99xtl> hm mn=ht:/w.3og19/hm" <edrnt"evr> ha ua=sre" <il>oi Cnrl/il> tteLgn oto<tte <ikhe=Syehe.s"tp=tx/s"rl"tlset / ln rf"tlSetcs ye"etcs e=Syehe" > <ha> /ed <oy bd> <omi=fr1 rnt"evr> fr d"om" ua=sre" <i> dv <s:oi I=Lgn"rnt"evr Csls=Lgnoto" apLgn D"oi1 ua=sre" sCas"oiCnrl> <ilTxSyeBcClr"666"Fn-od"re FrClr"FFF"/ Tteettl akoo=#B9B otBl=Tu" oeoo=#FFF > <apLgn /s:oi> <dv /i> <fr> /om www.c-sharpcorner.com/uploadfile/raj1979/login-control-in-asp-net-3-5/?login=true&user=sabh007@ 4/11

3/28/12

<fr> /om <bd> /oy <hm> /tl

Login Control in ASP.NET 3.5

If you running the page and if the CSS file is placed in a directory where anonymous access is denied, the add you web config file
<oainpt=Syehe.s" lcto ah"tlSetcs> <ytmwb sse.e> <uhrzto> atoiain <lo ues""> alw sr=*/ <atoiain /uhrzto> <sse.e> /ytmwb <lcto> /oain

You can add several hyperlinks to your Login control, such as hyperlink to a help text page, or a hyperlink to to a regi
<s:oi I=Lgn"rnt"evr Csls=Lgnoto" apLgn D"oi1 ua=sre" sCas"oiCnrl CetUeTx=Rgse" raesret"eitr CetUeUl"/eitrap" raesrr= Rgse.sx HlPgTx=Adtoa Hl"HlPgUl"/epap" epaeet"diinl ep epaer= Hl.sx Isrcinet"laeetryu ue nm adpswr frlgn" ntutoTx=Pes ne or sr ae n asod o oi.> <ilTxSyeBcClr"666"Fn-od"re FrClr"FFF"/ Tteettl akoo=#B9B otBl=Tu" oeoo=#FFF > <apLgn /s:oi>

Looks like this :

Here is .CS Code:


uigSse; sn ytm uigSse.olcin.eei; sn ytmCletosGnrc uigSse.iq sn ytmLn; uigSse.e; sn ytmWb uigSse.e.I sn ytmWbU; uigSse.e.IWbotos sn ytmWbU.eCnrl; uigSse.aaSllet sn ytmDt.qCin; pbi prilcas_eal :Sse.e.IPg ulc ata ls Dfut ytmWbU.ae { poetdvi Pg_odojc sne,Eetrse rtce od aeLa(bet edr vnAg ) { i (ti.sotak f !hsIPsBc) VeSae"oiErr" =0 iwtt[Lgnros] ;

poetdvi Lgn_uhniaeojc sne,AtetctEetrse rtce od oi1Atetct(bet edr uhniaevnAg ) { i (oraiainucinLgn.srae Lgn.asod) f YuVldtoFnto(oi1UeNm, oi1Pswr) { / eAtetctd=tu; / .uhniae re Lgn.iil =fle oi1Vsbe as; Msaeae.et="ucsflyLge I" esgLblTx Scesul ogd n; es le { eAtetctd=fle .uhniae as;
www.c-sharpcorner.com/uploadfile/raj1979/login-control-in-asp-net-3-5/?login=true&user=sabh007@ 5/11

3/28/12

Login Control in ASP.NET 3.5

poetdvi Lgn_oiErrojc sne,Eetrse rtce od oi1Lgnro(bet edr vnAg ) { i (iwtt[Lgnros]= nl) f VeSae"oiErr" = ul VeSae"oiErr" =0 iwtt[Lgnros] ; itErron =(n)iwtt[Lgnros]+1 n roCut itVeSae"oiErr" ; VeSae"oiErr" =Erron; iwtt[Lgnros] roCut i (Erron >3 & (oi1PswrRcvrUl! srn.mt) f (roCut ) & Lgn.asodeoeyr = tigEpy) Rsos.eietLgn.asodeoeyr) epneRdrc(oi1PswrRcvrUl;

piaebo YuVldtoFnto(tigUeNm,srn Pswr) rvt ol oraiainucinsrn srae tig asod { bo boRtrVle=fle ol oleunau as; srn sroncin="evr.dtbs=edruds;w=itlet" tig tCneto sre=;aaaeVno;i=apdwnelc;; Sloncinsloncin=nwSloncinsroncin; qCneto qCneto e qCneto(tCneto) Srn SLur ="EETUeNm,Pswr FO Lgn; tig QQey SLC srae asod RM oi" Slomn cmad=nwSlomn(QQey sloncin; qCmad omn e qCmadSLur, qCneto) SlaaedrD; qDtRae r sloncinOe(; qCneto.pn) D =cmadEeueedr) r omn.xctRae(; wie(rRa() hl D.ed) { i (UeNm = D[UeNm".otig) &(asod= D[Pswr".otig f (srae = r"srae]TSrn() Pswr = r"asod]TSrn { boRtrVle=tu; oleunau re D.ls(; rCoe) rtr boRtrVle eun oleunau; rtr boRtrVle eun oleunau;

If you insert wrong username and password then message will show like this:

If you insert right usename, password then redirect your page whereever you want or you can show message in Error

I am attaching my database with application in App_Data folder, if u want use my database then attach my .MDF file Any question and queries ask me any time.
Comment Request!
Thank ou for reading this post. Please post our feedback, question, or comments about this post Here.
Add your contents and source code to this article

Article E tensions
Contents added by Ganesh on Feb 05, 2010 but how to configure website administration tool and how to strore username and password in login folder of pur database?

www.c-sharpcorner.com/uploadfile/raj1979/login-control-in-asp-net-3-5/?login=true&user=sabh007@

6/11

Potrebbero piacerti anche