Introduction:
Creating a poll on your website enables you to find out more about the interests of the user. I recently added a weekly poll system to GridViewGuy. In this article I will explain how to create an AJAX enabled polling system using ASP.NET client callbacks.
Database Schema:
The database schema consists of only two tables:
1) PollQuestions: This table holds all the questions for the poll.
2) PollChoices: This table holds the choices of the poll questions.
Take a look at the schema shown below:

Poll Control Architecture:
I wanted to create the polling user control in a way that it does not depend on the Page. Let’s take a look at the class diagram below:

Now, let me explain each class in details:
IPoll: IPoll is an interface which will be used by all the polling classes.
WeeklyPoll: This is the class responsible for creating weekly polls. It implements the IPoll interface.
PollQuestion: This is an entity class which maps to the PollQuestions table in the database.
PollChoice: This is an entity class which maps to the PollChoices table in the database.
PollTableHelper: This is a helper class which is used to generate dynamic HTML tables.
ControlToHtmlConvertor: This class contains helper methods to convert a control into pure HTML.
DataAccess: This class serves as the DataAccess class and used to INSERT and SELECT polls from the database.
Implementation:
Let’s dive into the implementation details. We will see few important classes in this article. For complete implementation you can download the code at the end of this article.
IPollInterface: