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

How to generate strong random password in

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

generate strong random password in

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>
    <tr><td>Password : </td><td> 
        <asp:TextBox ID="txtpwd" runat="server"></asp:TextBox>     
    <tr><td></td><td> <asp:Button ID="Button1" runat="server" onclick="Button1_Click"
            Text="Generate Password" /></td></tr>

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.

What do you think about this article?

If you found this article useful, please share and follow on Facebook, Twitter, Google Plus and other social media websites. To get free updates subscribe to newsletter. Please put your thoughts and feedback in comments section.