Click to See Complete Forum and Search --> : Do you know an AJAX solution that doesn't have this issue?


DarkBob
05-14-2008, 07:30 AM
Ignore the first few posts, but they're here for reference. (http://www.webdeveloper.com/forum/showpost.php?p=891289&postcount=5)

Hi, I want to find the cleanest and optimal performing way to execute server side functions from the client and pass infromation back to the client.

Currently I'm using Client Callbacks, this would be fine if I only wanted to pass information to one callback function but the user can select options that require completely different server side functionality on the same page so I want to be able to call several different callbacks. Currently I use the callback as a marshalling point and append extra information to my argument string to indicate which function should be called but I was wondering is this really the best way.

Also does anyone know where I can find performance related info regarding the different callback techniques?

Thanks in advance for your help, any comments are welcome.

DarkBob
05-18-2008, 07:52 AM
Bump, I've answered a load of questions for other people but nobody as answered mine :(

chazzy
05-18-2008, 12:45 PM
let me understand better - you're calling numerous client callbacks for any single event that happens?

DarkBob
05-19-2008, 06:07 PM
Sorry reading that back I realise it's not the best explanation I've ever written, so here goes again.

I have a web application that has numerous functionalities, what I want is a fast simple way to be able to call different server side functions depending on the the type of interaction with the web application. Once the various server side functions are complete and the data is ready I want to return it to the client and call a callback on the client that was passed with the initial server function call.

Currently I'm using ASP .NET 2.0 Client Callbacks, when I wrote the original post I was just wondering if there was a better way to do this as I didn't like the fact that I could only call one virtual function on the server and I had to append information to the callback argument to then tell the server which function to call. I also didn't like the fact that I had to pass all the arguments in one string, so I was wondering if there was a better way.

Since then I've come accross another issue with client callbacks, if a second server side callback function is called before the first one returns and calls the client callback, then you only get one callback called on the client. This is a major issue when you're blocking functionality to certain parts of the page till you get a success call.

After looking into it further I think that client callbacks are too limited. I'm unfamiliar with AJAX and at this stage I'm a bit reticent to use other people's solutions so I'm gonna start another thread asking if AJAX has these issues. If not I'll use AJAX, if so I'll roll my own AJAX solution, which I'm kind of partial to do anyway as it will give me an opportunity to create a solution that has none of the problems of Client Callbacks and one of the features I think could be a big win is passing back a handle to the original callback data on error to make retrying very easy in case the connection fails, etc.

If you've got any info or comments to add I'd love to hear them,

thanks

Andy

DarkBob
05-19-2008, 06:19 PM
Hi, I recently posted here asking if Client Callbacks were the correct way to go with a web application I'm making. I didn't get much in the way of replies but I found out that for various reasons but one particular showstopper the answer was no.

The main issue I had with client callbacks is that if a second server side callback function is called before the first one returns and calls the client callback, then you only get one callback called on the client. This is a major issue when you're blocking functionality to certain parts of the page till you get a success call as you never get one.

Investigating further I found out that client callbacks sit on top of Microsoft's implementation of AJAX, I'm wondering if anybody know's if this limitation is inherent in all the AJAX implementations they've used or if this is a limitation that was added at a higher level when they were creating client callbacks.

I have a web application that has numerous functionalities, what I want is a fast simple way to be able to call different server side functions depending on the the type of interaction with the web application. Once the various server side functions are complete and the data is ready I want to return it to the client and call a callback on the client that was passed with the initial server function call.

If anybody here can point me in the direction of a good clean AJAX solution for this problem that would be great. If not I'll roll my own AJAX solution using XMLHTTP, which I'm kind of partial to do anyway as it will give me an opportunity to create a solution that has none of the problems of Client Callbacks (single server side function call and just one string argument) and one of the features I think could be a big win is passing back a handle to the original callback data on error to make retrying very easy in case the connection fails, etc.

If you've got any info or comments to add, caveats, alternatives I'd love to hear them.

Thanks,

Andy

chazzy
05-19-2008, 07:53 PM
Have you considered using the ASP.NET Ajax control toolkit (http://www.asp.net/AJAX/AjaxControlToolkit/Samples/)? I was kind of hoping of getting a better understanding of how you're using client callbacks (what functionality they're adding to your site, such as dynamically updated drop downs, redrawn div's, etc). I guess i'm trying to understand why it is you're sending multiple callbacks, or if it's just because your end users are faster than the network?

BTW, I'm going to merge this thread into the other, as it's really just a restatement of this issue.

DarkBob
05-19-2008, 08:51 PM
I'd rather have obliterated the old thread as it's no longer valid and I'm going to have edit my posts to ask new viewers to skip past it as it now does not reflect the question in the title. (I can't edit my old posts :()

As for how I'm using the callbacks; I have divs that are created dynamically in c# on page load. These divs display information from a database. A user can click on the div and edit the information, once they click save updating database appears over the div and it's not editable until the success callback is recieved and the updating database message is then destroyed. You can also drag these divs around and change their order on the page, this too triggers a callback that needs to affect the order information in the database not the actual data displayed in the div. So it's completely different functionality both server and client side that is required for this. I could disallow users from making multiple changes on different divs/orders at the same time but I'd rather not block the user if at all possible. The problem comes if the user calls a second callback before the first completes. I've had a cursory look over the microsoft implementation and it looks like it should be able to handle this case but the results show a different story. It's a little tricky to debug as it jumps between threads so I haven't tracked down exactly why it fails.

I'll check out the toolkit you sent me the link to but it's almost 2am so I'm gonna hit the hay for now. Thanks though, I do appreciate you taking the time to help!!

chazzy
05-19-2008, 10:07 PM
I added a note to the first post. I didn't realize when I did the merge that it left that as the first post, even though I merged the old thread into this thread. Weird.

I can't speak for every single AJAX control in the kit, but I believe if it's not in there there's definitely a pre-made drag and drop control out there somewhere. Based on what you described though, wouldn't it make a bit more sense to add a bit of blocking, instead of just putting what they enter directly into the DB, couldn't you hold an object in the session that stores the data temporarily, until the user hits the save button?

Of course, if you do want it to stay 100% stateless, there's definitely something in the AJAX toolkit. Just to point out, there's probably going to be a day or so of lead tie to understand the toolkit to its full capability.

DarkBob
05-20-2008, 09:10 PM
Hi, it's actually a real time system where multipe users can update the data simultaneously so need to I need to update the DB as soon as and deal with the race conditions. Otherwise delaying all calls would be a valid option. I do block updating on the specific object but I don't want to block the entire app.

I have to admit that I'm not that familiar with .Net controls I'm porting this code to .Net previously I used javascript with live connect to call functions in a java applet which opened a socket connection to a server app using DHTML to update the page. At work I only code in c++ and assembler, this is a home project I wrote the original code for this app about 10 years ago before ASP existed so I'm a little out of touch.

The drag and drop stuff is still fine and everythng else is fine too. I just wanted to know whether AJAX has the same problems I experienced with Client Callbacks namely not all successful calls calling the relevent callback successful function. I wanted to see if someone could give me this answer, to see if I could save myself the investigation.

(Sorry for being so obscure on what the app actually does but I've got a feeling a modified version of my old app could be a bit of a money spinner and I don't want people on the web being able to see and nick the idea)