8

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

3 Answers 3

4

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.

7
  • I'm having lots of Javascript errors using Timer + UpdatePanel... Do you have some example of doing it with jQuery? Thanks.
    – empz
    Commented Jun 10, 2011 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?
    – empz
    Commented Jun 10, 2011 at 18:46
  • You'll get that DLL from the P&P Enterprise Library site on codeplex: entlib.codeplex.com
    – James Love
    Commented Jun 13, 2011 at 18:02
  • I've downloaded Official release from here (microsoft.com/downloads/en/…) and there's no such DLL...
    – empz
    Commented Jun 13, 2011 at 18:43
  • 1
    I recommend you open up a new question with your JavaScript errors. Commented Jun 13, 2011 at 20:55
1

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.

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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