Pass values of checkBox to controller action in asp.net mvc4

后端 未结 12 1574
长发绾君心
长发绾君心 2020-12-14 00:31

I want to test if the checkbox is checked or not from my action method, what i need is to pass checkbox value from view to controller.

This is my view:



        
12条回答
  •  忘掉有多难
    2020-12-14 01:30

    None of the previous solutions worked for me. Finally I found that the action should be coded as:

    public ActionResult Index(string MyCheck = null)
    

    and then, when checked the passed value was "on", not "true". Else, it is always null.

    Hope it helps somebody!

提交回复
热议问题