2
votes

I’m in the middle of writing a blog site in asp.net (VB) and am trying to add thumbs up / down voting buttons to each article in an asp.net repeater control. The site is driven from an SQL database and im looking for the best way to achieve this? Im hoping to end result will have a similar look and feel to reddit, stackoverflow & youtube voting.

I’m using SQL membership for security and will request that the user logs in before they can vote. I know I will need to store the following values (article ID, user id, vote value) so the total can be updated and stop any duplicate voting.

I’ve created 3 tables (Articles, Votes, Users). The votes table will record each vote storing the (article id, userid, vote value). I have also added a ‘vote total’ field to the articles table which will be updated via a stored procedure each time a vote is made. This should help performance when showing the articles.

What I cant work out is the best way to implement the buttons against each article?

I would be extremely grateful for any advise, Thanks

1

1 Answers

0
votes

The voting control is within the repeater, and the repeater can store a unique ID to the article in each row, by using the DataKeys collection. If everything is being done server-side, you could retrieve the ID of the row using this data keys collection, and pass that along with the request to do the vote.

If you are talking client-side, then you'd have to store the article ID on the client somewhere (hidden field or other), and then extract it from the hidden when you go to push the request to the server.