Monday, March 26, 2012

Integrating Ajax into a SharePoint WebPart

Hello,

does anyone now how to use ajax within a webpart? In SharePoint Services V 3.0 the WebPart Class is just another component of ASP. NET 2.0 so it should be pretty easy. My question is where to import the libraies. Do I have to create WebPart pages that are ajax enabled?

thx for every help!

I've been using the client-side libraries that ship with ASP.NET AJAX beta 1 inside of SharePoint webparts - basically using the generated proxies to call webservices. I haven't played much with the controls ( and I think some of them are not fully supported in the current beta's of both products). Anyway, the basic steps are as follows:

1. Modify the web.config in your sharepoint root virtual directory to include all the ASP.NET AJAX Beta 1 settings.

2. Add the Microsoft.Web.UI control to your <SafeControls> list in the web.config.

3. Build the webpart. The gotcha here is that SharePoint will not allow you to run server-side code on an ungosted page. So if you create a page through Frontpage and embed the <asp:ScriptManager/> tags on it then it won't work. See this post for a work-around in this scenario (http://weblogs.asp.net/soever/archive/2006/07/27/SharePoint-2007_3A00_-using-ASP.NET-server-side-code-in-your-pages.aspx).

Besides embedding the <asp:ScriptManager/> tags you can also programatically add the controls to your page via the CreateChildControls() override. See an example here (http://daniellarson.spaces.live.com/Blog/cns!D3543C5837291E93!311.entry).

Thanks,

Matt


Matt,

I'm planning to use MS ASP.Net 2.0 Ajax framework with SharePoint.

What did you mean by including APS.NET Ajax settings, could you post a sample? Same for Microsoft.Web.UI control.

Thank you!

Lilia


Hi Lilia,

There are certain settings that need to be placed in your web.config file. My example is probably out of data because I haven't downloaded the final ASP.Net AJAX bits yet (still using beta). However, visit this bloghttp://daniellarson.spaces.live.com/Blog/cns!D3543C5837291E93!934.entry and you should find all the information you need to get going.

Thanks,

Matt


Matt,

I downloaded SharePointAJAX.wsp and RTM deploy.cmd into C:\Inetpub\wwwroot\wss\VirtualDirectories\80\bin on the web server and ran the script, which created SharePoint.Ajax.dll and .pdb files as well as altered web.config to include System.Web.Extensions. I added SharePoint.Ajax.dll to the VS05 project references but found that SharePoint.Ajax.DataLoader, .XmlTransform, and .XmlComponent methods don't show. Would these methods be used in the javascript web service?

I'm no very clear on what is needed to create Ajax-enabled controls for SharePoint. Would I have a web part (implemented in VS05) with a grid control for example and this .cs class would call a web service implemented with javascript (Ajax capability)?

Your help is very much appreciated.

Lilia

No comments:

Post a Comment