I've developed a custom web part that pulls data from a list. It will only retrieve items where a field called ShowItem is equal to 'Yes'. Once the data is loaded the end user has the ability to select an item and change the metadata on it. One of the fields they can change is ShowItem field. If they change that field value to 'No' it should no longer show that item in the web part. This works good if I refresh the web page with the web part but I want it to update automatically. Is this possible using jQuery or some other Javascript?

I should have mentioned that I only want the web part to refresh if the user has changed the field ShowItem to 'No'.

  • If you use Sharepoint Designer you can click on the automatic update to display a. But i noticed when i have an attachment link on the webpart and refresh it doesn't show the attachment. Any ideas? – naijacoder Jan 23 '12 at 7:29
  • Is this a Farm solution or a Sandboxed solution? – Anders Aune Jan 23 '12 at 11:03
  • It's a farm solution. – daver306 Jan 23 '12 at 16:08

You can always use Ajax for automatic refreshing.

Add a timer control into an Ajax Update panel within your custom web part and execute your code to refresh the field values within the Timer_Tick() event. You can also control the timer interval to 10 minutes or so using the Timer.Interval property. This will always enable your page to remain with only the web parts getting refreshed.

I just found a blog post which describes this in detail with screenshots.

Good Luck !!!

  • Thanks for the suggestion! Do you know if it's possible to manually refresh the update panel if a field value changes and not rely on the timer? – daver306 Jan 23 '12 at 16:13
  • 1
    The manual refresh would be to hit F5 on the page and the web part gets refreshed with the page regardless of the ajax timer. You can also think about adding a refresh button in the web part which calls the same code inside. This could give users an option to refresh manually regardless of the timer. – Deepu Nair Jan 23 '12 at 23:40

http://drewmace.blogspot.com/2008/02/auto-refresh-sharepoint-page.html http://www.sharepointmonitor.com/2010/04/auto-refresh-web-parts-in-sharepoint-2010/

  • 1
    In your link, the whole page is reloaded, not only the webpart. – Anatoly Mironov Mar 5 '12 at 10:47

Could you please help us understand more how you have implemented your custom webpart. Based on the answers i'm assuming you might be using Ajax UpdatePanel in your custom webpart.

How are you updating databack to List item? i'm assuming via some button click. If that's the case then it should be easy, you can call the DataLoading code(which gets the data from list based on ShowItem Field condition) again in the button-event handler.

Akhilesh Nirapure | Zevenseas

  • I used Sharepoint Designer to build the list.Its just a listview.But selected the Refresh button.Chrs – naijacoder Jan 27 '12 at 6:26

You can use javascripts post back event after editing a row e.g. __dopostback() event

  • this answer seems correct but need some more description like other answers – saber tabatabaee yazdi Dec 24 '13 at 6:10

It depends.. The simplest way (but maybe not the sexiest) is to use asp:UpdatePanel and bind postback triggers to your inputs (Yes No).

Alternatives to UpdatePanel are many (e.g. knockout.js + jQuery.ajax + jQuery tmpl).

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.