Click here to Skip to main content
15,889,808 members
Articles / Web Development / ASP.NET

Credit Card Validator control for ASP.NET

Rate me:
Please Sign up or sign in to vote.
4.79/5 (115 votes)
30 Aug 2002CPOL13 min read 858.6K   18.3K   283  
Article outlining how to create a credit card validator control fully derived from BaseValidator.
namespace DataCashTest {
	using System;
	using System.Collections;
	using System.Data;
	using System.Web.UI;
	using System.Web.UI.WebControls;
	using System.IO;
	using System.Text;
	using System.Security;
	using System.Security.Cryptography;

	public class MainPage : Page
	{
	
		protected TextBox CardNumber, StartDate, ExpiryDate, Issue, Amount;
		protected Label Result;
		protected Button ChargeCard;

		protected override void OnLoad(EventArgs e)
		{
			// Add event handler for the click on the button
			ChargeCard.Click += new System.EventHandler(this.ChargeCardOnClick);
			
			base.OnLoad(e);

			// Build the text boxes, provided nobody's clicked the button. If they have
			// then ViewState takes care of retaining the contents.
			if (!IsPostBack) {
				//Nothing to do
			}        
		}
		
		protected void ChargeCardOnClick(Object sender, EventArgs e)
		{
		
			if (IsValid)
			{
				// This is where the normal transaction processing would occur
			}
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United Kingdom United Kingdom
I graduated with a first class BSc honours degree in a Computer Science/Management Science hybrid Smile | :) from Loughborough University. I live in London and currently work as a .NET Developer in central London.

I'm also currently blogging my progress at further developing my articles into commercial components. Read my blog here.

I've also recently started dabbling at digital photography, and digital re-touching, and developing small simple multiplayer games in Flash.

Comments and Discussions