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

RadAjaxManager: Events from a trigger update UpdatedControls that are not linked to it

8 Answers 199 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
IvanB
Top achievements
Rank 1
IvanB asked on 20 May 2010, 07:57 PM
In my application I need all controls, that are inside specific panel, to trigger update on the same and possibly other panels. There are also panels that must not be updated by these controls. These panels however need to be updated by some other controls. Therefore I need to specify them as UpdatedControls in RadAjaxManager as well. For example in the code below I want Button1 to trigger update on UpdatePanel1, but not UpdatePanel2. However when I click Button1 UpdatePanel2 gets updated.

Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="RadAjaxManagerTest._Default" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server"
    <title></title
</head> 
<body> 
    <form id="form1" runat="server"
    <div> 
        <telerik:RadScriptManager runat="server" /> 
        <telerik:RadAjaxManager ID="ajaxManager" runat="server"
            <AjaxSettings> 
                <telerik:AjaxSetting AjaxControlID="UpdatePanel1"
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="UpdatePanel1" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
                <telerik:AjaxSetting AjaxControlID="UpdatePanel2"
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="UpdatePanel2" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
            </AjaxSettings> 
        </telerik:RadAjaxManager> 
        <asp:Panel ID="UpdatePanel1" runat="server"
            <asp:Label ID="Label1" runat="server" /> 
            <asp:Button ID="Button1" runat="server" Text="Button1" /> 
        </asp:Panel> 
        <asp:Panel ID="UpdatePanel2" runat="server"
            <asp:Label ID="Label2" runat="server" /> 
            <asp:Button ID="Button2" runat="server" Text="Button2" /> 
        </asp:Panel> 
    </div> 
    </form> 
</body> 
</html> 
Default.aspx.cs
using System; 
 
namespace RadAjaxManagerTest 
    public partial class _Default : System.Web.UI.Page 
    { 
        protected void Page_Load(object sender, EventArgs e) 
        { 
            Label1.Text = Label2.Text = "LastUpdated: " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); 
        } 
    } 
 

Is there a way to achieve what I need without explicitly specifying each control as a trigger(AjaxControlID)? I'm using 2010 Q1 release.
Thanks.



8 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 25 May 2010, 03:58 PM
Hello Ivan,

Please refer to the following help topic which elaborates on this matter. Test the provided approach and let us know if it helps.


Sincerely yours,
Maria Ilieva
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
IvanB
Top achievements
Rank 1
answered on 25 May 2010, 05:31 PM
Hello Maria,
it seems that what I'm trying to achieve is the exact opposite to what is discussed in the article. I do want all controls inside ajaxifyied container to perform callback, not postback. The problem is that all containers get updated - in my case both UpdatePanel1 and UpdatePanel2 get updated when I click Button1. Clearly UpdatePanel1 is not configured to trigger updates on UpdatePanel2, but it does. So my question is how to prevent this from happening.

Thanks
0
Lee Tucker
Top achievements
Rank 1
answered on 26 May 2010, 01:39 AM
Just to chime in, I'd really like a fix for this also. It seems to be an issue when using asp:Panels and other runat=server container controls like spans and divs as update targets with ajax manager. All container-controls get updated on an AJAX request regardless of which initiating control they are defined under. One container that does seem to work as expected is a RadAjaxPanel. If you replace the asp:Panels in the example with telerik:RadAjaxPanels it works for me. Maybe this behavior is somehow by-design but it would be great if the ajax manager would behave as configured for all initiator control and update controls relationships.
0
Maria Ilieva
Telerik team
answered on 27 May 2010, 01:48 PM
Hello,

Unfortunately the described behavior is known for the RadAjaxManger and asp Panels. If you add Panels to the RadAjaxManager setting this issue will occur. In scenario like this we suggest adding the content that need to be updated together in separate RadAjaxPanels instead adding Panels into the AjaxManager settings.

Sincerely yours,
Maria Ilieva
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
IvanB
Top achievements
Rank 1
answered on 07 Jun 2010, 06:55 PM
Hello Maria,
Since I want one (or more) panel(s) to trigger update on other panels multiple RadAjaxPanels won't work for me. Are you planning on fixing the behavior of RadAjaxManager?
0
Maria Ilieva
Telerik team
answered on 09 Jun 2010, 02:24 PM
Hello Ivan,

Currently we do not suggest adding such fix for container controls in RadAjax as its implementation will cause other issues and braking changes in the RadAjaxManager logic

 
Best wishes,
Maria Ilieva
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Sacha
Top achievements
Rank 1
answered on 07 Nov 2012, 05:49 PM
For anyone with this issue I have worked out a potential workaround which does work in my scenario but may not handle all others but certainly solved my issue.

Simply Add the controls to the UpdatedControls collection of the AjaxSetting on the Postback on the server side, it doesn't solve all scenarios but certainly can be useful as an option.
Note: Make sure you clear your other controls from the collection on postback.

Scenario: RadGrid with dynamically added triggers.

Markup:

 

<telerik:AjaxSetting AjaxControlID="rgDepartments" EventName="RadGridCustom">

    <UpdatedControls>

        <telerik:AjaxUpdatedControl ControlID="rgDepartments" />

    </UpdatedControls>

</telerik:AjaxSetting>


Code-behind:
Private Sub rgDepartments_DeleteCommand(sender As Object, e As Telerik.Web.UI.GridCommandEventArgs) Handles rgDepartments.DeleteCommand
  
Select Case e.CommandName
  
    Case Telerik.Web.UI.RadGrid.DeleteCommandName
  Dim oSetting = GetAjaxSettingByEventName("RadGridCustom")
  oSetting.UpdatedControls.Clear()
  oSetting.UpdatedControls.Add(New Telerik.Web.UI.AjaxUpdatedControl(oSetting.AjaxControlID, Nothing))
  oSetting.UpdatedControls.Add(New Telerik.Web.UI.AjaxUpdatedControl(rgEmployees.ID, Nothing))
     End Select
 
End Sub

 

Private Function GetAjaxSettingByEventName(eventName As String) As Telerik.Web.UI.AjaxSetting
For Each setting As Telerik.Web.UI.AjaxSetting In rampContent.AjaxSettings
If setting.EventName = eventName Then
Return setting
End If
Next
End Function


Ideally, you would clear the updated controls collection in the Page_Load and then simply handle it in the event handler as to what should be included in the postback.

 

0
Maria Ilieva
Telerik team
answered on 12 Nov 2012, 12:40 PM
Hello Sacha,

Thank you for sharing your approach. I'm sure it will be of a big help for our users.

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
IvanB
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
IvanB
Top achievements
Rank 1
Lee Tucker
Top achievements
Rank 1
Sacha
Top achievements
Rank 1
Share this question
or