Generate password Randomnly in asp.Net

Step 1:Take button And Label

Step 2:Create Method:

Write code following:

public static string createrandompwd(int pwdlength)
{
string _a = "0123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNOPQRST";
Random r = new Random();
char[] arr = new char[pwdlength];
int allchrcount = _a.Length;
for (int i = 0; i < pwdlength; i++)
{
arr[i] = _a[(int)((_a.Length) * r.NextDouble())];
}
return new string(arr);
}
}

Step 3:Button Double click:

Label1.Text = createrandompwd(7);