views:

240

answers:

4

I have before created a quick Ajax Framework for one of my projects. It was an ASP.Net Website (C#). There was not a lot of Ajax type functions so I just made a new Page with nothing in it and in the code behind file I put some code in the Page_Load method which would look for an action in the request and then call the appropriate method.

I am in the same scenario again and I am finding that I am tempted to do the same again. I am letting the user create a new accommodation. Two of the fields that belong with accommodation are accommodation type and area. Both of these fields are maintained by the users so they can CRUD both of these fields on other pages. I was thinking that if the area or accommodation type did not yet exist it would be irritating to have to go to another page. So instead I want to give them the functionality of adding new areas and adding new accommodation types on the same form. So I have tickboxes for the accommodation type, when they click new I present them a textbox they enter the value and click add. It makes an Ajax call to the database to add the value and then a new tickbox appears if successful else an error message. Very similar for area except I will be using a drop down list.

This time however I am using some jQuery too. I am not that familiar with jQuery's Ajax libraries YET. My question is, "Is there a...

  1. Better
  2. Easier
  3. Smarter
  4. More Extendable
  5. All of the above

way of doing this." If so can you please point me in the right direction.

+3  A: 

Given that with VS2008 there's support for AJAX already built into the IDE (and with jQuery support coming), I think you'll find it tough to come up with something which is not only a better user experience but also a better developer experience.

The Visual Studio team not only have a lot of resources invested in making this work well, but they also know how to integrate features into the IDE, almost certainly better than you do (and with more access to do so, I suspect).

If you want to do this for fun (or as part of MonoDevelop, for instance), that makes sense - but from a productivity point of view, I'd just stick to Visual Studio.

Jon Skeet
Hi Jon. I am using VS2005 at the moment. I have bought VS 2008 but was only wanting to move over once ASP.Net MVC was officially released. But this sounds like a reason to upgrade. Are you aware of any backward compatibility issues. I mostly have websites and 1 web app. Thanks in advance :D
uriDium
I don't know of any, but that doesn't mean there won't *be* any of course. Definitely worth upgrading though, mostly because you then get to use LINQ and C# 3 :)
Jon Skeet
I only partially agree with this, I have seen lots of hours lost to the built-in stuff, either because devs didn't understand it well or issues with some of parts of the ajax stuff - added an answer about this
eglasius
@uriDium, as Jon said linq and c# 3 are definitely worth the upgrade
eglasius
@Freddy: I strongly suspect it would take less time to understand the already-built stuff well than to build it all yourself. If your colleagues didn't understand C# well, would you get them a C# book or build them a new language?
Jon Skeet
@Jon I don't mean to go on and build a fully custom thing, you have to agree the updatepanel model is bogus and doing what you really should be doing isn't that well supported built in ... now if you combine jquery with the more clean server side asp.net support for it, that's another story
eglasius
Well, I'd spend more time understanding what's already there than building your own thing. That way your skills will be portable - and chances are there are significant reasons for odd-looking design decisions. Why waste ages only to find them later on?
Jon Skeet
+2  A: 

I dont think you need to create an entirely new Ajax Framework. A lot of time and effort by many people has been put into other frameworks like the Asp.net Ajax, jQuery, and others. Take some time to learn what these frameworks provide for you and how you can use them. If you still find them lacking nearly all of them have ways to extend on their already built features.

Corey Sunwold
+1  A: 

I'm not going repeat what Jon Skeet said and I am sure twenty other people are typing; however, if you decide to roll your own, instead of using a blank ASPX page, look into creating your own Http Handler. In visual studo you can create you own quick and dirty handler. They have an extension of .ASHX. The benefit here is you avoid the overhead of the page object framework.

JoshBerke
A: 

jQuery is in my experience a very good library with a lot of community support. Check out the jQuery IRC channel if you can't find what you are looking for in the documentation. We have an Ajax intensive application and it runs on jQuery as its core framework. We have been pleased with the results. If you are worried about size, Google hosts jQuery so your clients can cache it locally.

Alternatively, you may just want to create the proper HttpHandler(s) that will allow your client code to call server side resources without the overhead of a traditional ASP.NET Page class.

Check out this article from MSDN

Norman H