I am having a page with documents loaded in SharePoint 2010. I have three buttons below each documents in the page and they are 'Like','Unlike' and 'Comment'. So whenever people go there and see the documents they can click on any buttons of their wish.

My question is how to take the hit count of these buttons seperately and display it for each document. Is it possible to create a list with having these three columns and handle it using Client-Side scripting. Any suggestions or help is much appreciated.


from my understanding you have two methods!

1) server side... if your creating the buttons through code than it would be easy todo through server side as you can handle the button click event and write to a custom list that holds each value within three columns! within an updatepanel you can make it asif page is never reloaded but updates (ajax)

or client side, this you would need to send a post event to the same concept above!

now the key issue is:

1) is this for each document youll have the buttons? also ask are the document always gonna be the same or you going to upload docs that have the buttons (more dynamic).

If its static than your list is going to be more or less static meaning it shouldnt grow as there is a fixed ammount of documents.

if its dynamic (more or less documents at any given time) than your list is going to be dynamic so it will add and remove! This is a bit harder as I would highly suggest doing it serverside through c#. You would need to get the values from the list (ID) and connect it to the buttons:

so if you have three documents and each document has three buttons you want to link the doucment id to the custom list id as they would be unique! If you remove a document than you would also need to remove from the list (event reciver).

So to make it clear:


You dont need todo much appart from looking up the id from the document to the custom list and each of the button would contain this id, when you click a like button you would have some code within the click event that looks up for the custom list and than use the button id that should contain the id and its name to look witin the list as id would be unique for the row and name for column.

button id would looks somthing like : 1,like You would get the id and split the string from , to give you two values '1'(row) and 'like'(column). You can than get the value, add to it(increment) and add it back in!


this would be far more complex!!!! this would involve same as above for generating the ids for each button (id and name) also updating list on click event would be the same but you would also need to add an event handler on the document list so every time you added a new document it adds a new row to the custom list (to make it same id on row) and same goes for removing document item!

i would like to stress this is a very very basic method! if you want to make it more intuative you would need to think about adding another column for each document row, this would have a people count.... if you like or dislike (like youtube) than you would need to limmit the ammount you can like or dislike to only once! If you want to give only once and cant change than keep it to one column, if you want it youtube like where you can like or change your mide to dislike than you would need to create two columns of users, one for users who cliked like and the other for dislike! you would need to first check if the user is in any if he is in one than disable that one and let the other be visable so they can select the one they are not in..... this would become more complex as the user clicks like and gets added to like list of users, now the like button is disabled but the dislike is still enabled. You change your mind and click dislike so you need to check the user is in like list to see if they are in that list, if they are than remove them from that list and add to the dislike list and disable this button but now enable the like button!

You need to do this for either way and would recommend to make a method that checks for either way and adds/removes accordingly.

| improve this answer | |
  • Really thanks for your suggestion. I am supposed to achieve this using Client-Side and thats the reason I am confused. Since server side is restricted. – user3003821 Feb 14 '14 at 11:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.