Introduction: In this
article today I am going to explain how we can generate strong random password
in asp.net
Description:
In the previous article I have explained Send email tomultiple users in asp.net
(C#, VB), Send email tomultiple users selected in gridview using asp.net (C#, VB) , Take
automaticsnapshot (screenshot) and email it using asp.net (C#, VB) and Create Temporary table dynamically and
bind to Gridview 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.
No comments:
Post a Comment