Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I currently have a "Dashboard" full of CEWPs and DFWPs. It is required that the user can see the last update DateTime for each web part, which I would define as the greatest Modified DateTime of the list items displayed in each web part.

I would like to display this "Last Updated" DateTime in the Title of the WebPart.

I have build a VisualWebPart project in VS2010 that does this.

Now, I need to figure out how to extend this functionality to any web parts on the "Dashboard" or on any sites in general. Am I going down the correct path here? Is there a way for me to extend the base WebPart class so that all webpart types inherit this functionality.

Or...would it be better for me to simply write some client side script to iterate through all web parts on the page and then iterate through all of their list items, calculating the greatest Modified DateTime and then writing it to the Title bar.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Well, depending on the inheritance settings, subclassing might be a viable way. Some web parts are sealed, so you can't subclass them.

Personally, though, I'd consider doing this through JavaScript. It suspect that it'd be easier than the inevitable reverse engineering of existing web parts. The Client Object model is a good fit for this sort of thing. Also consider just using the REST API - it's good too, and I especially like it for queries and getting JSON format results.

Do not iterate to find the last update time. Do a query, ordering by modified date, and limit it to 1 result. It's much more efficient (and particularly easy with the REST API)

A final thought - you could write your own web part, and have it ONLY render a title bar as you want. Then on your existing web parts, you could turn the title bars off. If correctly positioned, your new web parts could look as if they're the titles for the existing web parts. (I've done similar things to that before now with the "Add new item" link).

I guess it depends how comfortable you are in Reflector, but I suspect that the client side script approach is easiest.

share|improve this answer
    
Thank you for your response. I'm behind on the Client Object Model technologies--have thus far just touched on JQuery. Can you get me up to speed by telling me what you mean by REST API? Is that JQuery. –  Loren S. Teillon Sep 6 '11 at 11:56
    
No. REST is a type of web service, which can be called from JQuery. Essentially, you request a URL of the form " /_vti_bin/ListData.svc/MyList?$filter=MyColumn eq 'Music' " and you would get the items in MyList where MyColumn equals the text Music. You can use this with jQuery's getJSON() method to get the results as JSON. See: msdn.microsoft.com/en-us/library/ff521587.aspx –  Andy Burns Sep 6 '11 at 15:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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