CS4 webControl25

CS4 webControl25

ListBox25

ListBox25 is a reusable ASP.NET helper control used to render single-select and multi-select list boxes using standard <select> elements. It supports labels, required indicators, Select2 integration, auto postback, JavaScript callbacks, and configurable widths.

Key Features

  • Single and multiple selection list boxes
  • Label with required (*) indicator
  • Predefined and custom widths
  • Select2 CSS class integration
  • Auto postback support
  • JavaScript callback on change

Public Enums

ListBoxType

ValueDescription
SingleSingle item selection
MultipleMultiple item selection

Size

ValueRendered Width
S150px
S2100px
S3150px
S4200px
S5250px
Max100%
Autoauto

SimpleListBox

SimpleListBox is used to render a single-selection dropdown list.

Properties

PropertyTypeDescription
ControlIdstringID and name of the select element
ValueListList<string>Display values
IdListList<string>Option values (optional)
SelectedValuestringSelected item value
LabelstringText label displayed above the list box
IsRequiredboolShows required (*) indicator
PlaceHolderstringSelect2 placeholder text
SizeSizePredefined width
CustomWidthintOverrides Size with custom width (px)
IsPostBackboolSubmits form on selection change
OnClickstringJavaScript function executed on change
IsHeaderboolRemoves bottom margin for header layouts

Sample Code – SimpleListBox

var listBox = new ListBox25.SimpleListBox
{
    ControlId = "Country",
    Label = "Country",
    IsRequired = true,
    ValueList = new List { "India", "USA", "UK" },
    SelectedValue = "India",
    Size = ListBox25.Size.S3
};

@ListBox25.GetHtml(listBox)

MultiListBox

MultiListBox is used to render a multi-selection list box.

Properties

PropertyTypeDescription
ControlIdstringID and name of the select element
ValueListList<string>Display values
IdListList<string>Option values (optional)
SelectedValuesList<string>Preselected values
LabelstringText label displayed above the list box
IsRequiredboolShows required (*) indicator
PlaceHolderstringSelect2 placeholder text
SizeSizeWidth of the control

Example – MultiListBox

var multiListBox = new ListBox25.MultiListBox
{
    ControlId = "Roles",
    Label = "User Roles",
    ValueList = new List { "Admin", "Editor", "Viewer" },
    SelectedValues = new List { "Admin", "Viewer" },
    Size = ListBox25.Size.Max
};

@ListBox25.GetHtml(multiListBox)