HTML flag grouping

Typically, HTML flags are grouped by name. Can I group a flag other than a name?

Thank!

0
source share
3 answers

Not in HTML. But you can write some server-side code logic that groups them based on some condition, for example. a common prefix or suffix in a parameter name or even a parametric value.

However, this is just awkward. Just capitalize on the HTML you gave, with the ability to group them by a simple name. If you have a problem with this, then you need to fix it somewhere else, perhaps with an element identifier (to indicate uniqueness in the document tree) or an element style class (to indicate a common value in the document tree).

+2
source

If you are using ASP.NET, you can use the MutuallyExclusiveCheckBoxExtender in the AjaxToolkit group to group. It groups them together, so that only one flag in a group can be checked at a time, like groups of radio objects.

http://www.asp.net/ajax/tutorials/creating-mutually-exclusive-checkboxes-cs

0
source

. ASP.Net ( ):

 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim allChk As New ArrayList(Me.CheckBoxList1.Items)
        allChk.Sort(New SortComparer(False))
        Me.CheckBoxList1.Items.Clear()
        For Each item As ListItem In allChk
            Me.CheckBoxList1.Items.Add(item)
        Next
    End Sub

    Public Class SortComparer
        Implements IComparer
        Private ascending As Boolean

        Public Sub New(ByVal asc As Boolean)
            Me.ascending = asc
        End Sub

        Public Function [Compare](ByVal x As Object, ByVal y As Object) As Integer Implements IComparer.Compare
            Return x.ToString.CompareTo(y.ToString) * DirectCast(IIf(Me.ascending, 1, -1), Int32)
        End Function
    End Class
0
source

All Articles