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'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'.

share|improve this question
    
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
add comment

5 Answers

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 !!!

share|improve this answer
    
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
add comment

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

share|improve this answer
1  
In your link, the whole page is reloaded, not only the webpart. –  Anatoly Mironov Mar 5 '12 at 10:47
    
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. –  Stuart Pegg Sep 3 '12 at 21:09
add comment

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.

Thanks
Akhilesh Nirapure | Zevenseas

share|improve this answer
    
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
add comment

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

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

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).

share|improve this answer
add comment

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.