When developing ASP. net mvc applications, a random string may be required as a password or verification code.
If you need the SQL version, you can refer to the password needs to carry special characters (2), http://www.cnblogs.com/insus/archive/2012/02/16/2354453.html
The implementation method in this article is referring to this implementation C # version.
Under the application, create a CharacterUtility. cs:
There are several static methods in this category:
1. Random lowercase letters:
2. generate random uppercase letters:
3. Random numbers:
4. Special characters are generated. You can define the character set:
Each of the above attributes can be randomly obtained with one character. Next, Insus. NET writes another method to obtain an 8-bit random string. Of course, you can define the length:
In the widget, write an Action and a method for executing jQuery:
Finally, you can create a view:
Real-time Demonstration: