Aug 31, 2023, 4:13 PM
CheckboxGroup.CheckedItems returns a list of all checked items for all Checkbox Group controls on the page
Package versions:
I've come across an odd error that appears to be related to the latest version of the Ext.NET.Utilities Nuget package. We recently upgraded this package from v2.2.1 to v2.5. After doing this, we found that, if a page contains multiple CheckboxGroup controls, accessing the CheckedItems property of a particular control returns a list of all checked items for all CheckboxGroup controls on the page, not just the CheckboxGroup control currently being accessed. The following sample demonstrates this:
- Ext.NET: 1.7.0
- Ext.NET.Utilities: 2.5.0
I've come across an odd error that appears to be related to the latest version of the Ext.NET.Utilities Nuget package. We recently upgraded this package from v2.2.1 to v2.5. After doing this, we found that, if a page contains multiple CheckboxGroup controls, accessing the CheckedItems property of a particular control returns a list of all checked items for all CheckboxGroup controls on the page, not just the CheckboxGroup control currently being accessed. The following sample demonstrates this:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="CheckboxGroups.Web.Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" EnableViewState="false" AjaxViewStateMode="Disabled" RethrowAjaxExceptions="true" />
<ext:Viewport ID="ViewportMain" runat="server" Layout="FitLayout">
<Items>
<ext:FormPanel ID="FormPanelMain" runat="server" Frame="true" ButtonAlign="Center" AutoScroll="true">
<Items>
<ext:FieldSet runat="server" Title="Valid Arrival Days" Width="360" HideLabels="True">
<Items>
<ext:CheckboxGroup ID="CheckboxGroupArrivalDays" runat="server" ColumnsWidths="48,48,48,48,48,48,48">
<Items>
<ext:Checkbox runat="server" Flag="1" BoxLabel="Mon" Checked="true" />
<ext:Checkbox runat="server" Flag="2" BoxLabel="Tue" Checked="true" />
<ext:Checkbox runat="server" Flag="4" BoxLabel="Wed" Checked="true" />
<ext:Checkbox runat="server" Flag="8" BoxLabel="Thu" Checked="true" />
<ext:Checkbox runat="server" Flag="16" BoxLabel="Fri" Checked="true" />
<ext:Checkbox runat="server" Flag="32" BoxLabel="Sat" Checked="true" />
<ext:Checkbox runat="server" Flag="64" BoxLabel="Sun" Checked="true" />
</Items>
</ext:CheckboxGroup>
</Items>
</ext:FieldSet>
<ext:FieldSet runat="server" Title="Not Valid for stays including" Width="360" HideLabels="True">
<Items>
<ext:CheckboxGroup ID="CheckboxGroupInvalidDays" runat="server" ColumnsWidths="48,48,48,48,48,48,48">
<Items>
<ext:Checkbox runat="server" Flag="1" BoxLabel="Mon" />
<ext:Checkbox runat="server" Flag="2" BoxLabel="Tue" />
<ext:Checkbox runat="server" Flag="4" BoxLabel="Wed" />
<ext:Checkbox runat="server" Flag="8" BoxLabel="Thu" />
<ext:Checkbox runat="server" Flag="16" BoxLabel="Fri" />
<ext:Checkbox runat="server" Flag="32" BoxLabel="Sat" />
<ext:Checkbox runat="server" Flag="64" BoxLabel="Sun" />
</Items>
</ext:CheckboxGroup>
</Items>
</ext:FieldSet>
</Items>
<Buttons>
<ext:Button ID="ButtonSave" runat="server" Icon="Disk" Text="Save">
<DirectEvents>
<Click OnEvent="SaveClick">
<EventMask ShowMask="true" />
</Click>
</DirectEvents>
</ext:Button>
</Buttons>
</ext:FormPanel>
</Items>
</ext:Viewport>
</form>
</body>
</html>
using System.Collections.Generic;
using System.Linq;
using Ext.Net;
namespace CheckboxGroups.Web
{
public partial class Default : System.Web.UI.Page
{
protected void SaveClick(object sender, DirectEventArgs e)
{
X.MessageBox.Show(new MessageBoxConfig
{
Message = $"Arrival Days: {ToCsv(CheckboxGroupArrivalDays.CheckedItems)}<br/>Invalid Days: {ToCsv(CheckboxGroupInvalidDays.CheckedItems)}",
Title = "Selected Items",
Buttons = MessageBox.Button.OK
});
}
private static string ToCsv(IEnumerable<Checkbox> checkboxes)
{
return string.Join(",", checkboxes.Select(x => x.BoxLabel));
}
}
}
Last edited by plok77; Aug 31, 2023 at 4:15 PM.