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:
This is the code behind:
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,
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">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
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,