How do I make a checkbox required on an ASP.NET form?

后端 未结 6 1234
隐瞒了意图╮
隐瞒了意图╮ 2020-11-28 02:51

I\'ve done some searching on this, and I\'ve found several partial answers, however nothing that gives me that warm fuzzy \"this is the right way to do this\". To answer the

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-28 03:24

    C# version of andrew's answer:

    
        
    

    Code-behind:

    protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
    {
        args.IsValid = CheckBox1.Checked;
    }
    

提交回复
热议问题