Showing posts with label services. Show all posts
Showing posts with label services. Show all posts

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

integration with asp.net services

Is there any documentation or examples online for creating atlas
applications that use the asp.net services?

Wally

--
Wallace B. McClure
"The Harder I Work, the Luckier I Get."
Listen to "The ASP.NET Podcast" at http://www.aspnetpodcast.com/
Database Award: http://url123.com/vc3er
Microsoft MVP - Visual Developer ASP/ASP.NET
AspInsider
"AJAX for ASP.NET" Coming Soon!
ADO.NET Book: http://url123.com/vc2bu
865-693-3004
118 Durwood Rd.
Knoxville, TN 37922
http://www.scalabledevelopment.com/
Blog: http://weblogs.asp.net/wallym/

Have you looked at theservices quickstarts? They have examples on doing this.

David


I have not seen any examples on integrating with things like membership,
authentication, and authorization. Do you have a URL?

Wally

wrote in message news:1196178@.66.129.67.202...
> Have you looked at the services quickstarts? They have examples on doing
> this.
>
> David
>
I have not seen any examples on integrating with things like membership,
authentication, and authorization. Do you have a URL?

Wally

wrote in message news:1196178@.66.129.67.202...
> Have you looked at the services quickstarts? They have examples on doing
> this.
>
> David
>
Sorry, I misunderstood your reference to "asp.net services" as meaning calling asmx asp.net web services from script. Let me check whether there is a sample relating to auth and membership.

The current integration with Membership and Forms authentication is limited to two methods on Web.Services.AuthenticationSerivce:

login

validateUser

The first method accepts a username, password and clientside event hookups for completion, errors and timeouts. Back on the server it validates the credentials with thedefault Membership provider. Assuming the call to ValidateUser succeeds, the "login" method returns a forms authentication cookie by calling FormsAuthentication.SetCookie(). When the call to ValidateUser succeeds, the result from "login" is true - failed credentials result in a "false" return value and no cookie.

The code for this looks something like:

function OnSubmitLogin() {
//Use the built in Atlas authentication service to make a call to the server.
//This call will verify credentials, and if the credentials are good, the server will
//issue a forms authentication cookie.
Web.Services.AuthenticationService.login(username.value, password.value, OnLoginComplete);
return false;
}

//The asynchronous completion event where you process the result of calling the server
function OnLoginComplete(result) {
password.value = '';

//On success there will be a forms authentication cookie in the browser.
if (result) {
username.value = '';
textLoggedIn.style.visibility = "visible";
textNotLoggedIn.style.visibility = "hidden";

buttonLoginLogout.innerText = "Click me to logout!";
buttonLoginLogout.onclick = OnSubmitLogout;
}
else {
textLoggedIn.style.visibility = "hidden";
textNotLoggedIn.style.visibility = "visible";
}
}

The "validateUser" works similarly to "login", but no forms auth cookie is set.


Awesome info. I had been scanning through the Atlas.js file and I was
trying to understand the difference between login and validateUser. That
info really helps.

Wally

wrote in message news:1197028@.66.129.67.202...
> The current integration with Membership and Forms authentication is
> limited to two methods on Web.Services.AuthenticationSerivce:
>
> login
>
> validateUser
>
> The first method accepts a username, password and clientside event hookups
> for completion, errors and timeouts. Back on the server it validates the
> credentials with the default Membership provider. Assuming the call to
> ValidateUser succeeds, the "login" method returns a forms authentication
> cookie by calling FormsAuthentication.SetCookie(). When the call to
> ValidateUser succeeds, the result from "login" is true - failed
> credentials result in a "false" return value and no cookie.
>
> The code for this looks something like:
>
> function OnSubmitLogin() {
> //Use the built in Atlas authentication service to make a call to the
> server.
> //This call will verify credentials, and if the credentials are good,
> the server will
> //issue a forms authentication cookie.
> Web.Services.AuthenticationService.login(username.value,
> password.value, OnLoginComplete);
> return false;
> }
>
> //The asynchronous completion event where you process the result of
> calling the server
> function OnLoginComplete(result) {
> password.value = '';
>
> //On success there will be a forms authentication cookie in the
> browser.
> if (result) {
> username.value = '';
> textLoggedIn.style.visibility = "visible";
> textNotLoggedIn.style.visibility = "hidden";
>
> buttonLoginLogout.innerText = "Click me to logout!";
> buttonLoginLogout.onclick = OnSubmitLogout;
> }
> else {
> textLoggedIn.style.visibility = "hidden";
> textNotLoggedIn.style.visibility = "visible";
> }
> }
>
> The "validateUser" works similarly to "login", but no forms auth cookie is
> set.
>
No problem. I had hoped that there was something I was missing in the
quickstarts. :-)

Wally

wrote in message news:1196977@.66.129.67.202...
> Sorry, I misunderstood your reference to "asp.net services" as meaning
> calling asmx asp.net web services from script. Let me check whether there
> is a sample relating to auth and membership.
>

Saturday, March 24, 2012

Invoking WCF web services from client script with MS Ajax RC1

Hello,

I've read through the Ajax documentation which shows some examples of invoking .asmx web services from client code but I couldn't find any information about doing the same with .svc WCF web services. Is this supported in the current Release Candidate of Ajax? If not, is this planned for future releases?

Thanks for your time.

No, svc is not currently supported. However it will be supported in upcoming "Orcas" release. Read ithere and search for "Support for WCF Web Services"

I'm intested by calling a wcf services with ajax

could anyone tell me which version of ajax let me use .svc files and how ? sinc the docs on the web are gone ..


thanks in advance :)