Click here to Skip to main content
12,547,501 members (41,242 online)
Click here to Skip to main content
Add your own
alternative version


14 bookmarked

Easy-to-use Web ASP.NET Chessboard Control

, 14 Sep 2007
Rate this:
Please Sign up or sign in to vote.
An article to help you create a chessboard on ASP.NET using VB.NET
Screenshot - Chessboardcontrol_Gideonlouw.gif


I searched many websites to find an easy website control chessboard to use, but could not find any. So, I have created a very easy to use chessboard control myself. Most other source code uses GDI graphics and Windows Forms. The logic I've used here is very easy and anybody can use it on a website. You only need .NET installed and you can copy the user control on any page.

Please note that I haven't added any logic to the control, but this can easily be built in if you want it.

Using the Code

The logic I've used to build the control is fairly simple. Firstly, create a table with 8 columns and 8 rows. Color-code the table into blocks with white blocks and black blocks. Now create 64 PANELS and 64 IMAGE CONTROLS. On your load event, set the images of the start-up position in chess and set those panels' visibility all to true. For all the other panels, set the visibility to false. To let the actual pieces move, you need to store the MoveFrom square and the MoveTo square:

Dim MoveTo As Integer
MoveTo = CheckBoxNr
Dim MoveFrom As Integer
MoveFrom = lblMove.Text
If MoveTo = MoveFrom Then
    'No Move Take Place
End If

Once you get the MoveFrom and MoveTo squares, you can execute a move. Currently, I haven't built in any code to evaluate if the move is correct. This board assumes the user knows how to move chess pieces, but this additional code can easily be inserted in the procedure that I've dimmed out, called PROCEDUREVALIDATEMOVE(MoveFrom,MoveTo).


So, to give a summary of the chessboard ASP.NET control: It is an HTML-type table with panels and images on each square, as well as a checkbox to check what piece moves to what square. I think this is the easiest and quickest way to create a chessboard that works on a website.

I hope this article can help you. If you want to, you can add a procedure to evaluate the piece moves to see if each move is correct before executing the move. If you make any changes to the code and updates, you are more than welcome to email me an updated copy of the source. Leave a message in the forum at the bottom of the article to get in touch.


  • 14 September, 2007 -- Original version posted


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
South Africa South Africa
Gideon Louw is a qualified MCSD and software professional.

He developed several industrial and government related applications that has successfully been installed all over the world.

You may also be interested in...


Comments and Discussions

Questionneed help Pin
sainipraveen0421-Sep-07 6:29
membersainipraveen0421-Sep-07 6:29 
AnswerRe: need help Pin
Louwgi24-Sep-07 21:38
memberLouwgi24-Sep-07 21:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.161018.1 | Last Updated 14 Sep 2007
Article Copyright 2007 by Louwgi
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid