简体   繁体   中英

I need to build a very light weight Ajax Engine using C# and ASP.Net. What do you suggest?

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.

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.

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.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM