The new CallBackEventreference

V

Varangian

Hello there

anyone knows about the new CallbackEventreference?

How does it really work... I made it working through a dropdown list..
I cannot understand how the "string arguments" works... how many
arguments can I pass and in what? how does it relates with the
javascript function"

thanks :)
 
B

Bruce Barker

it MS first attempt at supporting Ajax. the current implementation allows
the client to pass one string arg to the server, and the server to return
one string arg.

the easiest way to understand it, is to look at the javascript code it uses.
you will see the javascript uses a XmlHttp (or a hidden iframe) to make an
async call to the webserver. asp.net recognizes the client callback, and
fire the server Callback events.

GetCallbackEventReference just returns javascript code needed to make a
server call. you combine this with your other client javascript to call the
backend. you could bundle it in your own function like:

string cbReference = Page.ClientScript.GetCallbackEventReference(this,
"arg", "ReceiveServerData", "context");
string callbackScript = "function CallServer(arg, context)" +
"{ " + cbReference + "} ;";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(),
"CallServer", callbackScript, true);

then in client script to call the server with:

CallServer("datatosend","context");

then in your client script you define the function called when callback data
is recieved:

function ReceiveServerData(serverResponseArg,context)
{
// do something with server data
}


-- bruce (sqlwork.com)
 
V

Varangian

thanks for your reply was helpful a couple of more questions though...

thats a bit of a drawback to pass only one parameter.
what actually is "arg" .. I always see this but is it a value or what ?
or just something that means that is passing one argument and only
argument can be passed..

which is the real javascript function ... the CallServer or the
ReceiveServerData ?
thanks again :)
 

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
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top