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

Using AjaxRequest versus __doPostBack

2 Answers 230 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Brent
Top achievements
Rank 1
Brent asked on 23 Sep 2008, 05:18 PM
Hi, I've got a fairly complex scenario, but let me describe the overall idea and then see if you can point me in the right direction.

I am in an ASP.NET web app, using nested user controls (ascx files) and using the RadAjaxManager in the main aspx page.  This page contains the nested user controls, and by "nested" I mean that the aspx page contains several user controls, and each user control may contain other user controls.

GOAL: 
From clientside javascript in the main page, I want to call a server side method and have the individual server controls in my nested user controls, be updated / refreshed.

Here is what I have working:
 - I've written code in the RadAjaxManager1_AjaxRequest method of the main page, that calls a publicly exposed method in one of my nested user controls.
 - The call to RadAjaxManager1_AjaxRequest is kicked off by a javascript function in my main page.
 - The method that is called in the user control, sets the Visible property of a button that resides in that user control, to false.

PROBLEM:
With _AjaxRequest, all of the code is fired and runs, BUT, the button does not disappear.  In other words, that control isn't being updated by the RadAjaxManager, to reflect that it's visible property is false.

I've tried various <AjaxSettings> <UpdatedControls> settings on the RadAjaxManager, but nothing is working.

HOWEVER, from the same javascript function that calls the AjaxRequest method, if I instead use __DoPostBack where my target is a button with a click event, it DOES work.  That method is fired and the Visible property of a button is set to false, and the UI is refreshed and the button disappears.

So, I'm really wondering if you have any advice on what to look for.

And, am I trying to use the RadAjaxManager1_AjaxRequest inappropriately?

Thanks,
Brent

 

2 Answers, 1 is accepted

Sort by
0
Konstantin Petkov
Telerik team
answered on 25 Sep 2008, 11:14 AM
Hello Brent,

You should be able to accomplish this scenario with the help of RadAjaxManager as well. It seems you're close to the solution -- all you need is an appropriate AJAX setting.

When you call ajaxRequest from the client though, you have the AJAX Manager as AJAX initiator and need to put it in an AJAX setting. In this case however, you update a control in a WebUserControl so you cannot directly reference that button through the AJAX Settings Configurator (design-time). You can either wrap that user control in an ASP:Panel for example and set the panel as updated control when the manager initiates AJAX request (add RadAjaxManager -> Panel AJAX setting), or find the AJAX Manager instance on loading the user control (this article would be of help here) and add dynamically an AJAX setting so that the manager to be able to update the loaded button on the client.

I hope this helps!

Regards,
Konstantin Petkov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Brent
Top achievements
Rank 1
answered on 26 Sep 2008, 02:22 PM
Thanks.  The part that I was missing, was that I wasn't ajaxifying the AjaxManager itself.  It didn't occur to me that I'd need to ajaxify the ajax manager...
Tags
Ajax
Asked by
Brent
Top achievements
Rank 1
Answers by
Konstantin Petkov
Telerik team
Brent
Top achievements
Rank 1
Share this question
or