views:

246

answers:

2

I've been working on a website for quite some time that makes heavy use of ASP.Net 3.5 and it's many ajax features. I particularly use the ScriptManager to register WebServices (.asmx) a lot. I also use their $get('idnamehere') method all over the place. I'm not really using any Ajax.Net pre built tools (like from the Toolkit) everything is custom.

I'd like to make the move to jQuery, as it seems a lot more useful. What do I need to look out for? Is this even wise? Should I remove the ASP.Net ScriptManager from my masterpage all together?

here's a sample of what my JavaScript might currently look like:

function doSomethingAjaxy() {
   var dropDownList = $get('dropDownListClientIDHere');
   MyWebServiceIRegistered.CallSomething(dropDownList.value, onSuccess, onFail);
}
function onSuccess(result) {
   alert('OMGWEE: ' + result);
}
function onFail(result) {
   alert('OMGFAIL: ' + result._message);
}

Assuming the above, what would need to change if I moved to JQuery?

+1  A: 

You could still keep your asmx services and back end. Check out www.encosia.com for some great posts on calling asmx services with jquery. Fiddler is also helpful so you can see the requests you are generating and the response from the server. Hope this helps.

Chris Westbrook
+2  A: 

You can use jQuery's $.ajax() method to call ASP.Net web services just fine, without having the scriptmanager build the "callers" for you. Much more efficient. Like Chris said, encosia.com has a few excellent articles about this subject. $get() can be replaced with $('#idhere')[0] (returns the object), or omit the [0] to call any jQuery-specific methods.

A particular Encosia.com article you may want to check out is here:

http://encosia.com/2009/07/21/simplify-calling-asp-net-ajax-services-from-jquery/

Nicholas H