When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles
Message Board
Related Web Technologies
User Tips!
Coding Tips

Sample Chapters
Commonly Asked Message Board Questions
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Stump the SQL Guru!
XML Info
Author an Article
ASP ASP.NET ASP FAQs Message Board Feedback
Print this page.
Published: Saturday, July 10, 1999

Creating User Polls

It seems like every site has a poll on their start page these days, especially the big media sites, such as ABCNEWS.com and MSNBC.com, just to name a couple. Well, I've got news for you: it's time to conform. So, let's look at how we can add professional looking user polls to our ASP websites.

- continued -

We'll need two tables in a database to accomplish this. The first table is called Poll, and contains information on all of our Polls. The really isn't much information that it needs to store, just the Poll question and the run dates for the poll. Let's look at the structure for this table:

PollQuestionText (150)

DateStart and DateEnd are used to determine the running times of your polls. This way, you can create many polls, with some scheduled for the future. Also, you can bring back old polls, or easily show the results of older polls.

The second table will hold the questions for each of our polls, and will aptly be named PollOption:

QuestionTextText (100)

PollOption.PollID is a Foreign Key to Poll.PollID. It represents what poll this question belongs to. So, let's say we want to have a poll that asks, "Have you programmed Cold Fusion webpages before?" and runs from 7/13/99 to 7/20/99. We want to give the users two options to select, "Yes" and "No." Here's the steps we'd need to do:

    1.) Insert a row into Poll, setting PollQuestion to "Have you programmed Cold Fusion webpages before?", DateStart to 7/13/99 and DateEnd to 7/20/99.
    2.) Insert two rows into PollOption. Both rows would have Votes initially set to zero and PollOption.PollID set to the the Poll.PollID that was assigned in Step 1. For the first row, set QuestionText to Yes, and for the second row, set QuestionText to No.

That's it! It's that easy! Now, all we need to do is add some ASP code to the page that we want to display the poll/poll results. If you haven't already seen ABCNEWS.com's poll, I'd suggest checking it out; it has the UI I'm going after with my approach.

Once you're ready, let's move onto Step 2, where we'll look at the ASP code needed to make our polling system a reality!

  • Proceed to Step 2

  • ASP.NET [1.x] [2.0] | ASPFAQs.com | Advertise | Feedback | Author an Article