How to generate strong random password in asp.net | ASPMANTRA | Asp.Net,MVC,AngularJs,Jquery,Javascript,Sql Server AND WCF snippets and tutorial

How to generate strong random password in asp.net

Introduction: In this article today I am going to explain how we can generate strong random password in asp.net

Description:
generate strong random password in asp.net

We can generate the random password using ASP.NET Membership provider. ASP.NET Membership has a static method built in to generate password.


HTML markup of Page:
    <fieldset style="width:300px">
    <legend>Generate Random Password</legend>
     <table>  
    <tr><td>Password : </td><td> 
        <asp:TextBox ID="txtpwd" runat="server"></asp:TextBox>     
        </td></tr>
    <tr><td></td><td> <asp:Button ID="Button1" runat="server" onclick="Button1_Click"
            Text="Generate Password" /></td></tr>
    </table> 
    </fieldset>

On Button click write the below given code:
C# Code:
protected void Button1_Click(object sender, EventArgs e)
    {
String RandomPassword = System.Web.Security.Membership.GeneratePassword(10, 1);
        txtpwd.Text = RandomPassword;
    }

VB Code:
Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
        Dim RandomPassword As [String] = System.Web.Security.Membership.GeneratePassword(10, 1)
        txtpwd.Text = RandomPassword

    End Sub

Is this article helpful for you?

If yes post your comment to appreciate my work and fell free to contact me. You can like me on Facebook, Google+, Linkedin and Twitter via hit on Follow us Button and also can get update follow by Email.

Post a Comment

[blogger]

MKRdezign

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget