Home | Articles|Namespace|Interview Questions|Tools|Jobs|Projects|Community
Asp.net Tutorials

»Dotnet Ads
»Message Boards
Message Boards
Dotnet Books

»Member Details
Register
Login
LogOut
Submit Code
Submit Jobs
Submit Projects

»Competition
Community
Winners
Prizes
Write For Us
Members

»Other Resources
Links
Dotnet Resources

Generating Registration Image on FLY






This article focus on generating image on fly in asp.net. This is very basic functionality which you find on almost all the website which require registration of user. Example: Yahoo Registration require to type you secret string before you can successfully login, this feature has no. of reasons and i am not going into detail of why we want rather i am explaining here how we can. Look for Screenshot for better idea.















For demo purpose i am generating image on button click. But generally you require to generate image on page load event of registration form.










Ok back on coding.
Step1: Create a new web application
Step2: Open Code Behind Form of web application you have created.
Step3: Add Namespace for drawing Image.
using System.Drawing;
using System.Drawing.Imaging;

Step4: Write Code for Generating Random Registration String (Here: Generating Random string of 10 in length).










// Generate a random password with the specified length. The password will only
// contain digits and letters (either lowercase or uppercase)
public static string GetRandomPassword(int length)
{
Random rand = new Random();
System.Text.StringBuilder password = new System.Text.StringBuilder(length);
for (int i = 1; i <= length; i++)
{
int charIndex;
// allow only digits and letters
do
{
charIndex = rand.Next(48, 123);
} while (!((charIndex >= 48 && charIndex <= 57) ||
(charIndex >= 65 && charIndex <= 90) || (charIndex >= 97 && charIndex <= 122

Have a Question and dont know the answer post it below and get answers in minutes

Due to spam this feature is disabled
To get answers fast , make sure you enter a detailed subject for example: "DataGrid issues need answer" not "DataGrid"

Subject:

Catjegory Name:

Message:



© 2008 dotnetwatch.com -- Privacy policy

Website Design & Internet Marketing by Shivam