ToolBox Login Control Login

Login Web Server Control

in ASP.NET environment,This article describes you how to work with Login Web Control. The primary purpose of the Login control is to provide the UI control to authenticate into the website.In other words, The Login control is a composite control that provides all the common UI elements needed to authenticate a user on a Web site. The following three elements are required for all login sections:

  • user name -unique name to identify the user.
  • password -to verify the identity of the user.
  • login button -to send the login information to the server.
Styles
  • BorderPadding - The space between the control contents and the control's border.
  • CheckBoxStyle -Remember Me checkbox.
  • FailureTextStyle - Login failure text.
  • InstructionTextStyle -Instructional text on the page that tells users how to use the control.
  • LabelStyle -Labels for all input fields, such as text boxes.
  • TextBoxStyle -Text entry input fields.
  • TitleTextStyle -Title text.
  • ValidatorTextStyle -Text displayed to the user when a login attempt is unsuccessful due to validation errors.
  • HyperLinkStyle -Links to other pages.
  • LoginButtonStyle -Login button.

The following code snippets represents that a Login control to provide a UI for logging in to a Web site.

in .aspx.cs page,

bool IsValidEmail(string strIn)
{
    return Regex.IsMatch(strIn, @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]
    {1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"); 
}

void OnLoggingIn(object sender, System.Web.UI.WebControls.LoginCancelEventArgs e)
{
    if (!IsValidEmail(log1.UserName))
    {
        log1.InstructionText = "e-mail address is invalid.";
        log1.InstructionTextStyle.ForeColor = System.Drawing.Color.Red;
        e.Cancel = true;
    }
    else
    {
        log1.InstructionText = String.Empty;
    }
}

void OnLoginError(object sender, EventArgs e)
{
    log1.HelpPageText = "logging in...";
    log1.PasswordRecoveryText = "Forgot your password?";
}

The following code snippets explains how to work with MembershipProvider property of Login control .

in .aspx.cs file,

namespace Samples.AspNet.Controls
{
    public sealed class CustomLogin : Login
    {
        public CustomLogin() { }
        
        protected override void OnLoggingIn(LoginCancelEventArgs e)
        {   
            DropDownList list = (DropDownList)this.FindControl("domain");
            this.MembershipProvider = list.SelectedValue;
            base.OnLoggingIn(e);
        }
        
        protected override void CreateChildControls()
        {
            LayoutTemplate = new Temp1();
            base.CreateChildControls();
        }
    }
    
    public class Temp1 : ITemplate
    {
        void ITemplate.InstantiateIn(Control container)
        {
            TextBox UName = new TextBox();
            UName.ID = "UName";
            
            TextBox password = new TextBox();
            password.ID = "password";            
           
            CheckBox remember = new CheckBox();
            remember.ID = "RememberMe";
            remember.Text = "Don't forget me!";            
            
            Literal failure = new Literal();
            failure.ID = "FailureText";            
            
            DropDownList domain = new DropDownList();
            domain.ID = "Domain";
            domain.Items.Add(new ListItem("SqlMembers"));
            domain.Items.Add(new ListItem("SqlMembers2"));
            
                        Button submit = new Button();
            submit.CommandName = "login";
            submit.Text = "LOGIN";

            container.Controls.Add(new LiteralControl("UName:"));
            container.Controls.Add(UName);
            container.Controls.Add(new LiteralControl("
Password:")); container.Controls.Add(password); container.Controls.Add(new LiteralControl("
")); container.Controls.Add(remember); container.Controls.Add(new LiteralControl("
Domain:")); container.Controls.Add(domain); container.Controls.Add(new LiteralControl("
")); container.Controls.Add(failure); container.Controls.Add(new LiteralControl("
")); container.Controls.Add(submit); } } }
 
Related Links

Posted by: Admin
Posted on: 9/15/2009 at 4:55 PM
Tags: , ,
Categories: Asp.net
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (19) | Post RSSRSS comment feed

Comments

Onlineatoz.net

Tuesday, September 15, 2009 4:57 PM

trackback

ToolBox Login Control LoginName

ToolBox Login Control LoginName

cash loans United States

Friday, October 30, 2009 8:33 PM

cash loans

Nice resource. rss feed added

payday loans United States

Saturday, November 14, 2009 5:17 PM

payday loans

Interesting ... as always - is your blog making any cash advance ? ;)

online payday loans United States

Saturday, January 02, 2010 10:58 AM

online payday loans

Interesting post

Arizona Payday Loans United States

Monday, January 04, 2010 3:37 PM

Arizona Payday Loans

Interesting ... as always - is your blog making any cash advance ? ;)

payday loans United States

Wednesday, January 27, 2010 2:19 AM

payday loans

Well my friens .. as I always say ... Be polite to all, but intimate with few. Nice post.

cheap payday loans United States

Friday, March 26, 2010 8:04 AM

cheap payday loans

I am not really sure if best practices have emerged around things like that, but I am sure that your great job is clearly identified. I was wondering if you offer any subscription to your RSS feeds as I would be very interested and can?t find any link to subscribe here.

no fax cash advances United States

Saturday, March 27, 2010 7:48 AM

no fax cash advances

This is such a great resource that you are providing and you give it away for free. I love seeing websites that understand the value of providing a quality resource for free. It?s the old what goes around comes around routine.

quick loan online United States

Monday, March 29, 2010 11:06 PM

quick loan online

Hello. Great job. I did not expect this on a Wednesday. This is a great story. Thanks!

short term bad credit loans United States

Tuesday, March 30, 2010 8:55 AM

short term bad credit loans

I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well.

sagging skin after weight loss United States

Thursday, April 01, 2010 10:23 PM

sagging skin after weight loss

Interesting article. Were did you got all the information from? Anyway thank you for this great post!

payday loans United States

Friday, April 30, 2010 5:13 AM

payday loans

This is a really good read for me, Must admit that you are one of the best bloggers I ever saw.Thanks for posting this informative article.

personal loan for people with bad credit United States

Thursday, May 06, 2010 5:30 PM

personal loan for people with bad credit

Hello. Great job. I did not expect this on a Wednesday. This is a great story. Thanks!

moncler men People's Republic of China

Tuesday, June 22, 2010 10:21 AM

moncler men

Here elaborates the matter not only extensively but also detailly .I support the write's unique point.It is useful and benefit to your daily life.You can go those <a href=" http://conditions-encountered.com/ " >wslmart.net </a> sits to know more relate things.They are strongly recommended by friends.Personally

fast payday loans United States

Friday, July 09, 2010 7:23 PM

fast payday loans

You can only expand your capacities by working to the very limit

Timberland Boots sale United States

Thursday, July 29, 2010 11:45 AM

Timberland Boots sale

Through reading more good articles to improve our quality of life. Your blog make me feel comfortable. At the sametime,http://www.timberlandshoesonline.com I will introduce you to know about a comfortable shoes that makes your life better! you can choice what you like!

Timberland Boots sale United States

Thursday, July 29, 2010 11:54 AM

Timberland Boots sale

Through reading more good articles to improve our quality of life. Your blog make me feel comfortable. At the sametime,http://www.timberlandshoesonline.com I will introduce you to know about a comfortable shoes that makes your life better! you can choice what you like!

Timberland Boots sale United States

Thursday, July 29, 2010 11:56 AM

Timberland Boots sale

Through reading more good articles to improve our quality of life. Your blog make me feel comfortable. At the sametime,http://www.timberlandshoesonline.com I will introduce you to know about a comfortable shoes that makes your life better! you can choice what you like!

Payday Loans United States

Friday, July 30, 2010 2:44 PM

Payday Loans

I personally have embraced the new technologies and the CMS platforms, I think the new tools only make the web designs better. I am glad that new technologies are coming out in web design that make things easier, improved, and better looking for design.

Add comment




  Country flag

biuquote
  • Comment
  • Preview
Loading