문제

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

도움이 되었습니까?

해결책

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.

다른 팁

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.

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top