This is a migrated thread and some comments may be shown as answers.

AJAX Request to CodeBehind with returnvalue

1 Answer 332 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Alexander
Top achievements
Rank 1
Alexander asked on 07 Jul 2009, 08:06 AM
Hi all,

I'am currently evaluating the Telerik ASP.NET AJAX Controls.
I'am missing the functionality to invoke a AJAX Request which should call a function in the codebehind class asynchronly by providing a callbackfunction. The codebehindclass should return a value and call the callbackclass i provided with the returnvalue.

This works with WebServices which i registered within the ScriptManager but i think there must also be posibillity to do this with the CodeBehind Class. I've seen som peoples doing this, by using the function:
private void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
{
 
//code to handle the generic AJAX request
}

But then i need to return the value by putting it into a hidden input field. Thats no solution for me because i have several asynchron requests.

I hope you can help me.

Thank you

Alex



1 Answer, 1 is accepted

Sort by
0
Accepted
Veli
Telerik team
answered on 09 Jul 2009, 02:07 PM
Hello Alexander,

In this case you can try the following. Define a javascript callback function in your page. The function will take as parameter a string value returned from the server.

Then, in RadAjaxManager's server-side AjaxRequest event, register a response script that will call this callback function with any string parameter you give it from the server. The server-side event will look like:

void RadAjaxManager1_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e) 
    RadAjaxManager1.ResponseScripts.Add(String.Format("callBack('{0}')""Server Response!")); 

where callback() is my callback function defined in the HTML that will receive my server-returned parameter.

Best wishes,
Veli
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Ajax
Asked by
Alexander
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or