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

We have developed a Visual Web Part for Sharepoint 2010 with Visual Studio 2010 (Visual Web Part project template).

The web part loads some stuff and shows a list of items. It takes some seconds to do this, so we need to load it async. through ajax to avoid delay in the page load. We also need to refresh it every X seconds (async too).

I'm new at Sharepoint, but I have some .NET expertise.

What would be the best approach to accomplish this? Does Page Methods exist in Sharepoint? For the client-side part would you go for jQuery?

UPDATE

I have tried with the ASP.NET Timer + UpdatePanel solution but I'm getting lots of Javascript errors. I've found this possible solution, but I can't find that DLL and anyway I think that's for Sharepoint 2007

share|improve this question
add comment

3 Answers

up vote 4 down vote accepted

jQuery is one way to do this (feels like everyones choice nowadays). Since you're using a Visual Web Part an ASP.NET Timer control in combination with an UpdatePanel might be a preferred choice in your case, that will also fix both your problems; delay load and refresh.

share|improve this answer
    
I'm having lots of Javascript errors using Timer + UpdatePanel... Do you have some example of doing it with jQuery? Thanks. –  emzero Jun 10 '11 at 18:29
    
So I found this msdn.microsoft.com/en-us/library/ff647244.aspx but I don't know where to download that DLL. Any idea? –  emzero Jun 10 '11 at 18:46
    
You'll get that DLL from the P&P Enterprise Library site on codeplex: entlib.codeplex.com –  James Love Jun 13 '11 at 18:02
    
I've downloaded Official release from here (microsoft.com/downloads/en/…) and there's no such DLL... –  emzero Jun 13 '11 at 18:43
1  
I recommend you open up a new question with your JavaScript errors. –  Wictor Wilen MCA MCM MVP Jun 13 '11 at 20:55
show 2 more comments

Take a look at my answer here.

If you want to use AJAX with SP 2007, you'll have some setup to do. You'll need to setup your web.config to allow AJAX at all so I'd recommend checking out the AJAX.config feature that is a part of http://features.codeplex.com/. You might want to consider using Version=3.5.0.0 instead of 1.0.

Once you have AJAX enabled, you'll need a ScriptManager somewhere on your page. The easiest way to do this is just use SharePoint Designer to add it to the site's masterpage.

share|improve this answer
add comment

jQuery + WCF REST / JSON service hosted in ISAPI folder is a good solution for achieving AJAX functionality in SharePoint 2010.

Einar Otto Stangvik has a good blog post on how this can be done (with video and and source code) Building a WCF REST + jQuery webpart based realtime request graph for SP2010, in less than 5 minutes

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.