ToolBox Login Control PasswordRecovery

PasswordRecovery Web Server Control

in ASP.NET environment,This article describes you how to work with PasswordRecovery Web Control.The primary goal of the PasswordRecovery Control is to Displays an user interface (UI) controls that can be used to recover or reset a lost password and retrieving through the e-mail.In other words, This PasswordRecovery control helps the user who have forgotten their password.

Template property
  • UserNameTemplate
  • QuestionTemplate
  • SuccessTemplate
Views or States
  • UserName view - Asks the user for his or her registered user name.
  • Question view - Requires the user to provide the answer to a stored question to reset the password.
  • Success view -Tells the user whether the password recovery or reset was successful.
Styles
  • SubmitButtonStyle -Submit buttons on all views.
  • FailureTextStyle -Error text displayed to the user.
  • HyperLinkStyle -Links to other pages.
  • 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 for each view.
  • SuccessTextStyle -Text displayed to the user when the password recovery or reset attempt is successful.

The following code snippets demonstrates the PasswordRecovery control.

in .aspx.cs page,

void PasswordRecovery1_UserLookupError(object sender, System.EventArgs e)
    {
        pr1.LabelStyle.ForeColor = System.Drawing.Color.white;
    }
    
    void PasswordRecovery1_Load(object sender, System.EventArgs e)
    {
        pr1.LabelStyle.ForeColor = System.Drawing.Color.blue;
    }              

in .aspx page,

<html>
<body>
    <form id="FORM2" runat="server">
 <asp:PasswordRecovery ID="pr1" runat="server" BorderStyle="Solid" 
   BorderWidth="1px" BackColor="#F7F7DE" Font-Size="10pt" Font-Names="Verdana" 
        BorderColor="#CCCC99"
            HelpPageText="Need help?" HelpPageUrl="recoveryHelp.aspx" 
            OnUserLookupError="PasswordRecovery1_UserLookupError"
            OnLoad="PasswordRecovery1_Load">
            <SuccessTemplate>
                <table border="0" style="font-size: 10pt;">
                    <tr>
                        <td>
                            Your password has been sent to you.</td>
                    </tr>
                </table>
            </SuccessTemplate>
            <TitleTextStyle Font-Bold="True" ForeColor="White" 
            BackColor="#6B696B"></TitleTextStyle>
        </asp:PasswordRecovery>
    </form>
</body>
</html>
                        
 
Related Links

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

ToolBox Login Control LoginView

LoginView Web Server Control

in ASP.NET environment,This article describes you how to work with LoginView Web Control.The LoginView Control can Display the suitable content template for a given user, based on the user's authentication status and role membership.Moreover, which can be displaying different suitable templates for the different users.

Template Properties
  • AnonymousTemplate - Specifies the template to display to users who are not logged in to the Web site. Users who are logged in will never see this template.
  • LoggedInTemplate - Specifies the default template to display to users who are logged in to the Web site but do not belong to any role groups with defined templates.
  • RoleGroups -Specifies the template to display to logged-in users who are members of roles with defined role-group templates. Content templates are associated with particular sets of roles in RoleGroup instances.

The following code example explains how to work with 3 template of the LoginView control.

<html>
<body>
    <form id="FORM2" runat="server">
<p>
    <asp:LoginStatus ID="LoginStatus1" runat="server"></asp:LoginStatus>
</p>
<p>
    <asp:LoginView ID="lv1" runat="server">
        <AnonymousTemplate>
            log in.
        </AnonymousTemplate>
        <LoggedInTemplate>
            Thanks for logging in
            <asp:LoginName ID="ln1" runat="Server"></asp:LoginName>
            .
        </LoggedInTemplate>
        <RoleGroups>
            <asp:RoleGroup Roles="Admin">
                <ContentTemplate>
                    <asp:LoginName ID="ln2" runat="Server"></asp:LoginName>
                    , you have logged.
                </ContentTemplate>
            </asp:RoleGroup>
        </RoleGroups>
    </asp:LoginView>
</p>
    </form>
</body>
</html>                    
                    
 
Related Links

ToolBox Login Control LoginName

LoginName Web Server Control

in ASP.NET environment,This article describes you how to work with LoginName Web Control.The LoginName control provide the name that exist in the User Property of the Page class.The Control will not be provided when the System.Web.UI.Page.User.Identity.Name property is empty. By using FormatString property, We can change the text displayed by the LoginName control.

The following code snippets shows how to work with the LoginName.

in .aspx.cs page,

void Button1_Click(Object sender, EventArgs e) {
        LoginName1.FormatString = "your text";
         Button1.Visible = false;
    }

in .aspx file,

<html>
<head>
</head>
<body>
    <form id="Form2" runat="server">
        <p>
            <asp:LoginName id="LoginName1" runat="server" 
               FormatString ="Thanks, {0}" />
        </p>
        <p>
            <asp:Button id="Button1" onclick="Button1_Click" runat="server" 
               Text="Change" />
        </p>
    </form>
</body>
</html>
                    
 
Related Links

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

ToolBox Login Control LoginStatus

LoginStatus Web Server Control

in ASP.NET environment,This article describes you how to work with LoginStatus Web Control.The LoginStatus control provide states of the Authentication Process.morevoer,Detects the user's authentication state and toggles the state of a link to log in to or log out of a Web site. This control contains two states as following,

  • logged in - when logged in to the server
  • logged out - when logged out to the server
To add a LoginStatus button in a page
  • in Design view,Add a LoginStatus control to your page.
  • Customize the text displayed in the button by setting the LoginText and LogoutText properties.
To add a login or logout images
  • Add a LoginStatus control to your page.
  • Set the LoginImageUrl and LogoutImageUrl to the URL of the image to display as login and logout images, respectively.
  • Optionally customize the alt text displayed for the image by setting the LoginText and LogoutText properties.
 
Related Links

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

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 (77) | Post RSSRSS comment feed