You can use the below
namespace and class to generate Random Password.
Namespace : using System.Web.Security;
Class : Membership
Function : GeneratePassword
Now move the mouse on the GeneratePassword
method. it contains two parameter which defines in the below image.
aspx.cs code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
public partial class _Default :
System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string Password
= Membership.GeneratePassword(6,
2);
Label1.Text = "New
Password is:" + Password;
}
}
Now press CTRL+ F5 to run the application and test it.