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

Dynamic content updated by RadAjaxManager

2 Answers 178 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 30 Sep 2009, 08:11 AM
I hope this question hasn't been asked/answered before..

On a page we have a div that is filled with dynamic content; it's populated via a JavaScript AJAX method so we can set a refresh timer, refreshing the data every 3 minutes.  The initial load of this div is called from Page_Load but not on PostBack.  There are User Controls on the page that when used can require the div to update it's content, in these cases the User Control will add to Response Scripts a call to the JavaScript AJAX method.  To keep the update seemless we added a RadAjaxManager to link those User Controls to the div.

<telerik:AjaxSetting AjaxControlID="UserControl">
    <UpdatedControls>
        <telerik:AjaxUpdatedControl ControlID="UserControl" />
        <telerik:AjaxUpdatedControl ControlID="dynDiv" />
    </UpdatedControls>
</telerik:AjaxSetting>

The problem is that the User Controls won't _always_ require the div to update its content and in the cases where it shouldn't it won't add the JavaScript call to Response Scripts, but the RadAjaxManager will still update the div, refreshing it to it's initial state (a loading gif).

I've tried programmatically adding AjaxSettings for the specific buttons in the User Control that may update the div.  This was in the code behind of the User Control using a reference to the main pages RadAjaxManager, but those buttons won't always update the div so it'll still cause the problem, just in fewer circumstances.

I hope I explained the situation well enough and hopefully someone has some help to offer :)

Mike.

2 Answers, 1 is accepted

Sort by
0
Accepted
Veli
Telerik team
answered on 02 Oct 2009, 02:30 PM
Hi ekim,

You should not, actually, set RadAjaxManager settings for this scenario. You are not updating your div from the server side, but you are registering a client script on page that does the update. In this scenario, no AJAX update is required for a the div when your user control postbacks. I believe you will solve your issue by simply removing the AJAX setting for the div in your RadAjaxManager settings:

<telerik:AjaxSetting AjaxControlID="UserControl"
    <UpdatedControls> 
        <telerik:AjaxUpdatedControl ControlID="UserControl" /> 
    </UpdatedControls> 
</telerik:AjaxSetting> 

Thus, your user control and the div are not linked with AJAX in any way (as there is no need for that). Buttons inside your user control can now successfully register startup scripts that update the div on postback (say, click events). Now only your UserControl is AJAX-ified, so that you get asynchronous postbacks inside the user control, while the div is updated outside of the AJAX callback of the user control.

Regards,
Veli
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Mike
Top achievements
Rank 1
answered on 05 Oct 2009, 03:07 AM
I feel like a right idiot, the answer was so simple!

Thanks.
Tags
Ajax
Asked by
Mike
Top achievements
Rank 1
Answers by
Veli
Telerik team
Mike
Top achievements
Rank 1
Share this question
or