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

Can the OnAjaxRequest property of the RadAjaxManager be set programmatically?

3 Answers 82 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Dana Cobb
Top achievements
Rank 1
Iron
Dana Cobb asked on 09 Nov 2012, 04:04 PM
It says in the documentation that you can only have 1 RadAjaxManager on a page... I am thinking that I could really use the RadAjaxManager to be multi-purpose! I am currently triggering the ajaxrequest from closing a spawned radwindow) see code below...
//OnClientClose function
function runthisOnWindowClose() {
$find("<%= RadAjaxManager1.ClientID %>").ajaxRequest();
}

I was thinking that if I wanted to refresh my parent page from a second spawned radwindow ( on it's onclose event)....I would need to call a different code-behind function from the same RadAjaxManager's onajaxrequest property. So wouldn't it be nice if I could dynamically set the onajaxrequest from the codebehind when using a different popup.

Dana


3 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 10 Nov 2012, 02:12 PM
Hello,

Please try with below code snippet.

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
        function myContentClickHandler() {
            $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("content");
        }
    </script>
</telerik:RadCodeBlock>



Thanks,
Jayesh Goyani
0
Dana Cobb
Top achievements
Rank 1
Iron
answered on 12 Nov 2012, 03:05 PM

Thanks for getting back to me Jayesh,
    Just to be sure I understand, because although I have worked with some of the controls for years, I have never pushed the envelope for ajax. Would your example be basically the same as this section of the manual? http://www.telerik.com/help/aspnet-ajax/ajax-add-ajaxrequest-to-client-event.html
It seems to be relevant, but I just wanted to be sure. Regarding "eventargs"... these are probably a basic concept, but I have never really used them either. Is there a tutorial online that you feel would represent a good understanding of eventargs? I was able to successfully pass a string through recently 'RadGrid1', which allowed me to then do an if/then statement in the Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As AjaxRequestEventArgs)
procedure, but I feel like I am only scraatching the surface and would like to make sure I have a thorough understanding.

Regarding the initial topic of this post....could the ajaxrequest be made multi-purpose by programmatically setting the

 

OnAjaxRequest="RadAjaxManager1_AjaxRequest">

 property to the name of a 'second' event handler in the code-behind like...

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"  OnAjaxRequest="ADifferentAjaxEventHandler">
 
like.......
 
Protected Sub ADifferentAjaxEventHandler(sender As Object, e As AjaxRequestEventArgs)
 
        'Do something completely different in this handler then the normal "RadAjaxManager1_AjaxRequest"
End Sub


so that after a postback you could prepare the page to run a completely different function? and even switch back to the original on a nother postback?

Thanks in advance,
Dana

 

 

 

 

 



0
Maria Ilieva
Telerik team
answered on 15 Nov 2012, 02:44 PM
Hi Dana,

More about the ajaxRequest(eventArgs) client function could be found here:
http://www.telerik.com/help/aspnet-ajax/ajax-client-side-api.html
http://www.telerik.com/help/aspnet-ajax/ajax-pass-more-arguments.html

As for the different AjaxEventHandlers note that the required functionality could not be achieved. You could simply attach one event handler and conditionally based on the ajaxRequest arguments execute different server logic.

Kind regards,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Ajax
Asked by
Dana Cobb
Top achievements
Rank 1
Iron
Answers by
Jayesh Goyani
Top achievements
Rank 2
Dana Cobb
Top achievements
Rank 1
Iron
Maria Ilieva
Telerik team
Share this question
or