views:

525

answers:

4

Well, my latest contract is forcing me into the antique world of .Net 1.1.

Since I have been using jQuery and Rails for quite a while AJAX like solutions to problem keep on popping into my head and I can't help writing them.

So my fairly straight forward problem is that I have 3 actions I need to perform on a record (insert, update and delete) I can handle index and show using ASP.Net controls and javascript.

I am using jQuery for all my AJAX stuff.

The way I thought of doing this is introducing a simple ASPX page that acts as a controller for these three actions, giving it an anemic view and handling all rendering of return data using string concatenations. Is there a better pattern to use here? How did you hack ajax into ASP.Net 1.1?

I saw this post on ajaxprojects that is using a somewhat similar technique except they are doing 1 page per ajax action.

+3  A: 

We used to use ajax in classic ASP simply by posting XML messages to an ASP page that would load the xml from the request body.

You could do this using an ASHX page (ASP.Net handler) You won't have any of the extra overhead of the page objects. So you can basically create an Xml payload (or json or whatever you want) post it to the ashx page which has a single method which will inspect the request perform what you need and return the results you need.

JoshBerke
ashx does sound like a better option
Sam Saffron
A: 

Continue rolling your own with jquery isn't a bad idea but obviously you'll have to "reinvent the wheel" creating basic ajax support in existing controls. The fastest way to complete the project would be to track down the last versions of Infragistic controls that support .NET 1.1.

I wouldn't be surprised if they still had 1.1 flavors in their 2007 packages as they are pretty good about compatibility.

TravisO
A: 

I used AjaxPro for my 1.1 projects with quite a lot of success. The model that I used was to build up usercontrols to represent the 'views' then in the ajax requests I'd dynamically load the usercontrol and call the Render() method on the control.

When you call Render() it will write the HTML for your control to a text writer which you can then return to client via your ajax call and insert into a placeholder div.

lomaxx
+1  A: 

Hi,

The more you leave the Web Control paradigm, and the less viewstate you use, the simpler it will get, which is amazing but true. However, ASP.NET development shields us from HTML, CSS, and JavaScript, and few ASP.NET devs are prepared to immediately deal with them so directly, so taking the middle ground at first is probably best.

The good news is, ASP.NET 1.1 plays very well with jQuery and you can do anything you want, from avoiding web controls altogether and just using raw HTML with jQuery, to making full use of ASP.NET and sprinkling in just a little jQuery to, say, validate on the client and thereby avoid a postback.

An example of taking a middle route might be to create a normal datagrid, ideally off on a separate page, surrounded by only a form element (with runat=server removed), or perhaps just a div element, and serving it up via the jQuery ajax load method.

I personally do not use any of the Microsoft Ajax libraries. Every time I see people using them in samples, they seem to only complicate that which jQuery already does simpler and faster and better. This stuff is straightforward, don't make it ugly and slow by pulling in unnecessary MS libraries and using bulky XML without some really good reasons. I also personally remove all ViewState from all pages, and haven't yet found a case where ViewState did anything useful for me that wasn't simpler and more efficient just to handle directly. It turns out we never needed it, but Ajax sealed the deal. And the decrease in page size with corresponding increase in speed is a revelation. Living more fully in the actual web paradigm is so much simpler and better than living with leaky ASP.NET magic.

HTH.

Mike

P.S. Wow, everyone is coming on board to simpler, better web development: Controlling HTML in ASP.NET WebForms

Mike
Looking at Asp.Net 1.1 after a year of Rails development is really scary :) stuff seems so bloated and messy, on top of that the project I am working on has no CSS, all presentation is inline, its shockingly ugly
Sam Saffron
I realise this is months old, but that link is great Mike, wish I'd seen that last year!
Kirschstein