.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Encryption & Decryption >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Generate password Charactor Randomnly in asp.Net

Posted By:Dinkar       Posted Date: April 11, 2011    Points: 40    Category: Encryption & Decryption    URL: http://www.dotnetspark.com  

This C# function is used to geterate Generate password Charactor Randomnly in asp.Net
 

Generate passwordCharactor Randomnly in asp.Net

Step 1:Take button And Lable

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);
}

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend