raise_passwordStrengthCalculating

5 posts, 0 answers
  1. SSirica
    SSirica avatar
    50 posts
    Member since:
    Jan 2007

    Posted 22 Mar 2012 Link to this post

    I ran across a java script function called raise_passwordStrengthCalculating but I can't find any documentaion on it or how to use it?  See I've figured out a way how to get a value from a database into a password field, but I haven't figured out how to get the password field to calculate the password strength.  And I think that function would do it, but can't quite wrap my head around how to call it.

    I guess I didn't get my secret decoder ring along with my subscription.
  2. SSirica
    SSirica avatar
    50 posts
    Member since:
    Jan 2007

    Posted 22 Mar 2012 Link to this post

    There has got to be a way manually invoke the password strengthchecking via code?  You guys have such nice tools why do you make them so hard to navigate?
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. SSirica
    SSirica avatar
    50 posts
    Member since:
    Jan 2007

    Posted 23 Mar 2012 Link to this post

    OK I figured out how to invole this.  I'm using Subroutine:
    Sub setTelerikValue(oObj As Object, sVal As String)
        Dim sScript As String = "<script language='javascript'>" & _
                                "function f() {$find(""" & oObj.ClientID & """).set_value('" & sVal.Trim & "'); " & _
                                "$find(""" & oObj.ClientID & """).raise_passwordStrengthCalculating();" & _
                                "Sys.Application.remove_load(f);}; " & _
                                "Sys.Application.add_load(f);</script>"
        ClientScript.RegisterStartupScript(Me.GetType(), "setPass", sScript)
    End Sub

    Now I'm getting an error in my OnClientPasswordStrengthCalculating java function:
    function CalculatingStrength(sender, args) {
            //throw new Error;
            document.getElementById("<%=txtPassScore.ClientID%>").value = args.get_strengthScore();
    }

    args is empty, so it throws an error.  What am I missing?
  5. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 26 Mar 2012 Link to this post

    Hi,

    You need to construct the event args that you want to pass to the client event.

    var eventArgs = new Telerik.Web.UI.PasswordStrengthCalculatingEventArgs(Value, Score, LabelText);
    RadTextBox1.raise_passwordStrengthCalculating(eventArgs);

    The Value that you pass in the upper code, will be the same as args.get_strengthScore() will return in your handler later.

    And if you actually want to make the input to calculate the score and call the event, you need to use this code:
    Telerik.Web.UI.PasswordStrengthChecker.prototype.showStrength(TextBox1, TextBox1._textBoxElement, TextBox1._passwordSettings);
    where TextBox1 is the client object of your textbox.

    Regards,
    Vasil
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  6. SSirica
    SSirica avatar
    50 posts
    Member since:
    Jan 2007

    Posted 26 Mar 2012 Link to this post

    Dude you ROCK!!!  That worked perfectly!!!  I can't thank you enough.  For anyone else interested this is the final working version of the Subroutine: 

    Sub setTelerikValue(oObj As Object, sVal As String)
        Dim sScript As String = "<script language='javascript'>" & _
                                "function f() {var Obj = $find(""" & oObj.ClientID & """); " & _
                                "Obj.set_value('" & sVal.Trim & "'); " & _
                                "Telerik.Web.UI.PasswordStrengthChecker.prototype.showStrength(Obj, Obj._textBoxElement, Obj._passwordSettings); " & _
                                "Sys.Application.remove_load(f);}; " & _
                                "Sys.Application.add_load(f);</script>"
        ClientScript.RegisterStartupScript(Me.GetType(), "setPass", sScript)
    End Sub

    and this is how you'd call it:
                setTelerikValue(txtPassword, "PasswordValueHere")

    That will set a password field and force the calculation of the password strength. 

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017