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

RadAjaxManager causing events to fire incorrectly

2 Answers 66 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
EmpowerIT
Top achievements
Rank 2
EmpowerIT asked on 26 Aug 2010, 02:48 AM
I have a page that is using a RadAjaxManager to update some controls on the page. The controls that get updated can either be visible or not depending on some condition when the page is first loaded. The RadAjaxManager however still lists both of the controls as being p[art of the updated controls. I have found that if an invisible control is part of the updated controls, the AjaxControl for which it belongs will be incorreclty fired on the second postback, even though no event has been raised. Below is a simple page reproducing the problem (i took a while to track it down!)

ASPX:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FayezTest.aspx.cs" Inherits="Utilities_FayezTest" %>
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="script1" runat="server">
    </asp:ScriptManager>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="WorkClassificationValue">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="WorkClassificationValue" />
                    <telerik:AjaxUpdatedControl ControlID="EmployeeValue" />
                    <telerik:AjaxUpdatedControl ControlID="SitesValue" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="EmployeeValue">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="EmployeeValue" />
                    <telerik:AjaxUpdatedControl ControlID="Test" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <div>
        <telerik:RadComboBox ID="WorkClassificationValue" runat="server" CssClass="DatabaseFieldName"
            AutoPostBack="true" Width="100%" AllowCustomText="true">
            <CollapseAnimation Duration="200" Type="OutQuint" />
            <ExpandAnimation Type="OutQuart" />
        </telerik:RadComboBox>
        <asp:Panel ID="EmployeeSection" runat="server" Visible="false">
            <table class="DatabaseField" id="Table2" runat="server">
                <tr>
                    <td class="DatabaseFieldLeft">
                        <asp:Label ID="Label3" Text="Add Employees:" runat="server" CssClass="" />
                    </td>
                    <td class="DatabaseFieldRight">
                        <telerik:RadComboBox ID="EmployeeValue" runat="server" AutoPostBack="true" Width="100%"
                            ShowToggleImage="True" ShowMoreResultsBox="true" EnableVirtualScrolling="true"
                            Height="120px" AllowCustomText="true" EmptyMessage="Please type or select employee name">
                            <CollapseAnimation Duration="200" Type="OutQuint" />
                            <ExpandAnimation Type="OutQuart" />
                        </telerik:RadComboBox>
                    </td>
                </tr>
            </table>
            <br />
        </asp:Panel>
        <asp:Panel ID="SiteSection" runat="server">
            <telerik:RadComboBox ID="SitesValue" runat="server">
            </telerik:RadComboBox>
        </asp:Panel>
        <asp:Label ID="Test" runat="server"></asp:Label>
    </div>
    </form>
</body>
</html>

This is the code behind:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LogicRoster.Business;
using Telerik.Web.UI;
using EmpowerIT.Applications;
using System.Collections;
 
public partial class Utilities_FayezTest : System.Web.UI.Page
{
     
    protected void Page_Load(object sender, EventArgs e)
    {
       
        EmployeeValue.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(EmployeeValue_SelectedIndexChanged);
 
        WorkClassificationValue.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(WorkClassificationValue_SelectedIndexChanged);
 
       if(!this.IsPostBack)
       {
           EmployeeSection.Visible = true;
           SiteSection.Visible = false;
 
           WorkClassificationValue.Items.Add(new RadComboBoxItem("Item #1", "1"));
           WorkClassificationValue.Items.Add(new RadComboBoxItem("Item #2", "2"));
           WorkClassificationValue.Items.Add(new RadComboBoxItem("Item #3", "3"));
 
           EmployeeValue.Items.Add(new RadComboBoxItem("Item 1", "1"));
           EmployeeValue.Items.Add(new RadComboBoxItem("Item 2", "2"));
           EmployeeValue.Items.Add(new RadComboBoxItem("Item 3", "3"));
       }
    }
 
  
 
    void WorkClassificationValue_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        EmployeeValue.ClearSelection();
        EmployeeValue.Text = "";
    }
 
    void EmployeeValue_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
    {
     
        Test.Text += String.Format("Selected value is: '{0}'<br/>", e.Value);
    }
 
}


As you can see, in the Page_Load event, I intially set the SiteSection.Visible property to false. However, the control in this section, SiteValue, is listed as an item that will be updated by WorkClassificationValue. In this example it is not updated at all, however its updated was goverened by wether or not the section it was in was visible. If you select an item from the WorkClassificationCombo, and then select an item from the EmployeeCombo, you will notice that on the post back for the EmployeeCombo, the WorkClassificationValue_SelectedIndexChanged will fire incorrectly and end up clearing the selected value for the EmployeeValue combo.
If i remove the RadAjaxManager and use full postbacks, everything behaves as expected. Also, if set the SiteSection.Visible property to true, everything also behaves as expected.

Could someone please help or let me know if this is expected behavior or a known bug.

Thanks,

2 Answers, 1 is accepted

Sort by
0
EmpowerIT
Top achievements
Rank 2
answered on 26 Aug 2010, 02:50 AM
I should point out that I am using the 2010.2.713.40 version of the Telerik.Web.UI dll (.NET 4)
0
Iana Tsolova
Telerik team
answered on 31 Aug 2010, 08:16 AM
Hi EmpowerIT,

Indeed, it is not suggested to add invisible controls to the ajax settings. Therefore I suggest that you either set the ASP:Panel wrapped around the invisible ComboBox as UpdatedControl in the ajax settings. Or add a dynamical ajax setting for the ComboBox only for the cases when it is visible.

Regards,
Iana
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
Tags
Ajax
Asked by
EmpowerIT
Top achievements
Rank 2
Answers by
EmpowerIT
Top achievements
Rank 2
Iana Tsolova
Telerik team
Share this question
or