How to get checkbox value from FormCollection?

后端 未结 5 491
耶瑟儿~
耶瑟儿~ 2021-01-02 03:18

I have a checkbox and button:

@using(Html.BeginForm())
{
    
5条回答
  •  情书的邮戳
    2021-01-02 03:28

    I have tried out with input tag and it works as shown below:

    Remember Me?

    In the controller, compare the string value and convert its to a boolean.

    bool rmbMe = (formdata["chkRmb"] ?? "").Equals("on", StringComparison.CurrentCultureIgnoreCase);
    

提交回复
热议问题