Check if a checkbox is checked in a group of checkboxes in clientside

前端 未结 3 1889
忘了有多久
忘了有多久 2020-12-22 01:32

Please note that the scenario is ASP.NET Webforms + Master - Content page which mess up the ids.
I have, say, three checkboxes



        
3条回答
  •  误落风尘
    2020-12-22 02:16

    You could do this very easily with a CheckBoxList and a Dado.Validators which provides support for CheckBoxLists. Note this provides client-side and server-side validation.

    
        
        
        
        
    
    
    
    

    Example codebehind.aspx.cs

    btnSubmit.Click += (a, b) =>
    {
        Page.Validate("vlgSubmit");
        if (Page.IsValid) {
            // Validation Successful
        }
    };
    

    There are many other useful feature in Dado.Validators worth a look-see.

    https://www.nuget.org/packages/Dado.Validators/

提交回复
热议问题