Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
|
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 29th, 2009, 11:12 AM
Friend of Wrox
 
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
Arrow Displaying the password strength

Hello guys,
I am just trying to insert the password strength field. For that I have added the label next to password textbox. But I want to show the strength as soon as the user moves to next password field or some other field.
For this I have tried the code with CreatingUser & Databinding events but they do not work as I want. Can you please tell me what event would be beneficial for it so that password strength is shown as soon as user moves to next input field.

My markup is as follows.

Code:
<tr>
                                <td align="right">
                                    <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label>
                                </td>
                                <td>
                                    <asp:TextBox ID="Password" runat="server" TextMode="Password"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="PasswordRequired" runat="server"
                                        ControlToValidate="Password" ErrorMessage="Password is required."
                                        ToolTip="Password is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                    &nbsp;Password Strength:
                                    <asp:Label ID="lblPassStr" runat="server" ForeColor="Green" Visible="true"></asp:Label>
                                </td>
                            </tr>
And code behind file contains.

Code:
protected void CreateUserWizard1_DataBinding(object sender, EventArgs e)
    {
        if (CreateUserWizard1.ActiveStep.Title == "CreateUser")
        {
            Label PassStr = (Label)CreateUserWizardStep1.ContentTemplateContainer.FindControl("lblPassStr");
            //PassStr.Visible = true;
            if (CreateUserWizard1.Password.Length < 5)

                PassStr.Text = "Password Too Short, Not Acceptable";

            else if (CreateUserWizard1.Password.Length >= 5 && CreateUserWizard1.Password.Length <= 8)

                PassStr.Text = "Password is weak";

            else
                PassStr.Text = "Password is strong";

        }
    }
Any help is remarkable.
Thank you.
 
Old December 29th, 2009, 11:25 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

If you want this to happens on the client side, you should use javascript or at least ajax (to make a little round trip an execute the code on your side)...

The way you are implementing it, will only work when that event is executed, and that only happens when you load the page.
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old December 29th, 2009, 12:12 PM
Friend of Wrox
 
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
Arrow

Thanks for reply.
I am using Visual studio 2008, which is ajax enabled. But what control in the ajax toolbox is appropriate for that. That is what ajax control can be used for password display meter.
Thanks.
 
Old December 29th, 2009, 01:58 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

An update panel? with an event that is fired when you lost focus??
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old December 29th, 2009, 02:19 PM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Seriously, the best and EASIEST way to do this would be with a Regex validator.

You use a Regex validator just like you use any of the other validators. All you need to do is to come up with a regular expression that expresses what you need.

If you want to ensure that the password is at least 5 characters long, you could use {5}.
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}

Last edited by Lee Dumond; December 30th, 2009 at 06:45 PM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Why ASP.NET with SQL Server, and why PHP with MySQL, what is strength and weakness taev Visual Web Developer 2008 1 November 23rd, 2009 06:40 PM
Password Strength Verification vinodhanandhan .NET Framework 1.x 0 December 10th, 2006 04:45 AM
Password strength derekl ASP.NET 1.0 and 1.1 Professional 0 November 17th, 2006 06:35 AM
Detecting the field strength of a PDA DarkAtrox Pro Java 0 September 18th, 2006 12:16 PM
Password rajuru PHP Databases 1 February 10th, 2005 12:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.