0

I am learning how to create a website using ASP.NET & C#. Right now I am learning making AJAX requests & outputting the response. I have lots of experience with websites & using python/php server side & javascript + html client side.

Whats the best practice method to perform AJAX requests in an ASP.NET website? Is it JQuery or C#/ASP.NET?

Is it better practice to use native C#/ASP.NET AJAX calls/code?

// I think its something like
<asp:AJAX ....>

Does it matter which method is used?

Are you able to give a simple example in ASP.NET of how to write an AJAX request/call? I know how to do it in JQuery & also native Javascript but not in ASP.NET.

1
  • 2
    Simplest answer: Use MVC
    – SLaks
    Feb 20, 2012 at 2:50

2 Answers 2

2

Since you're asking this question, you probably realize that there are a few different ways of doing things. Unfortunately, with so many different options you have to actually make a choice, which can be difficult.

There is no 'proper' way to use AJAX with your ASP.net site, as they all have their pros and cons. It all about what will be the easiest for you (and any team members) to write, read, and maintain.

There are several controls built specifically to use AJAX (by using a ScriptManager control on the page that imports all kinds of useful JS). Things like the UpdatePanel can help make AJAX-y partial-postback things on a page really simple to write and maintain. There are also tons of other neat controls in the AJAX Control ToolKit that give you even more pre-built controls to use.

If you're looking for a more 'traditional' AJAX experience, you can make life easy by using PageMethods. You can also look into things like Web Services (kind of deprecated, but you'll still find them all over the place, and WCF services to make things as painless as possible. These can be called via your code-behind, asp, or jquery/js.

So, in short, just as with everything else in web development, there is no 'right way', just the right was for you.

-1

In ASP.NET, AJAX is utilzed by UpdatePanel control.

See these resources:

http://www.asp.net/ajaxlibrary/act.ashx

http://www.asp.net/ajaxlibrary/act_tutorials.ashx

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.