Main Topics
Browse All TopicsWith SharePoint event handlers it is quite easy to find events which delete, move or add items to lists. I want to attach some code to the View event (for example to increment listitem view count). How would I do this when there are no events for that available?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
The above solution will work for List. The "DispForm.aspx" will be used to display the listitem. you can edit the "DispForm.aspx" in desinger and add the user control / create a new display form in sharepoint designer and add the user control to it.
But the above solution will not work for Document Library. DispForm.aspx of Document Library used to display item's properties.. when you calick the document from document library, the browser will open the document, you can't increase the view count here.
I think of the following workarounds,
1) creating a Http Handler to increase the item view count when a item from document library is requested.
2) convert the list view web part to data form web part using sharepoint designer, change the link url of each item to open in new form using window.open(url). Append the query string with doc path. ex. "mydispform.aspx?url=http:
create a new page "mydispform.aspx" and add a content editor web part. Add javascript to read the querystring and set href to the querystring url (doc path).
Also add the user control for increasing the item view count.
Now, when you click a document it will open "mydispform.asx?url=docpat
Thank you very much for your thorough explanation.
Today I've been doing a few things to get this done.
1. I made a usercontrol which RunWithElevatedPrivileges to change the itemcount (in my case it is a different field, but it serves well as an explanation).
2a. I adjusted a data view by making it contain the XSLT data. In there I could adjust the HREF to move to the dispform.aspx. The HUGE drawback of this solution is that it is near impossible to easily adjust the views (e.g. add new columns to the view - this has to be done through SharePoint Designer, and even then it can be quite a hassle).
2b. I made a simple usercontrol which uses javascript to examine the current dataview and changes the direct link to the document to go to the dispform.aspx.
I will award you the points because I am really happy with 1 and 2b.
However, I am a little bit wondering one more thing. Perhaps you have an answer to it.
When making a view over a document library you can specify the columns you want to show. This includes the filename (with menu),, filename (with link to document) etc. Is there an easy way to make a custom column that you can call filename (with link to display form)?
This solution would obvious be 2c and be preferred over any of the other options.
Thanks for your time.
You can create a HTML calculated column to navigate to DIspForm.aspx. refer the following for creating HTML calculated column.
This will give you good start
http://blog.techgalaxy.net
Business Accounts
Answer for Membership
by: zabiullahPosted on 2009-04-06 at 06:03:37ID: 24076879
There is no event available to track the view item, you can try the following
1) Create a column "View Count" in your list to hold the hit rate.
2) Create an User Control and write code to increase the count of the current item's "View Count" column value by 1 in page_load event.
3) Add this User Control to "DispForm.aspx". Now the count will be increased by 1 for the respective list item for each "DispForm.aspx" load.