Callbacks in ASP.NET 2.0

M

Mark

I've a couple of questions to ask about callbacks in ASP.NET 2.0.

Apparently they changed since beta 2 (and those in charge of the MSDN
didn't get notified), because RaiseCallbackEvent() now returns void and
there's a new method in ICallbackEventHandler called
GetCallbackResult(). That's not so big a deal, I can make a new global
var to hold the argument (given to RaiseCallbackEvent) and use it in
GetCallbackResult.

However, one thing really does bother me. The code goes to all the
bother of gathering up all the form values to post together with the
callback data, which is great. I want to know in RaiseCallbackEvent all
the new values on the form (otherwise I'd have to put them all together
in the eventArgument parameter and parse them out on the server).
However, wasn't I surprised to learn that it gathers up all the form
data -only- when the page loads, and never again.

At the bottom of my page gets written out the following:

<script type="text/javascript">
<!--

WebForm_InitCallback();// -->
</script>

I figured I could just call this before I ran my callback. Wrong again.
This function relies on two variables, __theFormPostData and
__theFormPostCollection, which it does not bother to clear. In order to
get up-to-date values for my server-side controls in RaiseCallbackEvent
I have to do the following:

function CallServer(arg, context)
{
__theFormPostData = "";
__theFormPostCollection = new Array();
WebForm_InitCallback();
WebForm_DoCallback('__Page',arg,callback,context,null,false);
}

This all seems somewhat wrong to me. Am I trying to do something here
that was never forseen? Was this set up this way on purpose?

Mark
 
B

Bruce Barker

i agree with you, the behavior seems odd, but it looks like its posting the
inital values, so that the callback handler can detect onchange events.
though it hard to see how this would work on a second postback from the same
control. as there is no docs on the expected behaviour, its hard to tell.

i still can not get a simple example to run in firefox, get scripting
errors. the new model of generating the scripts is a pain for debugging and
patching.

-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top