Passing selected value from the radio buttons to the controller in MVC

前端 未结 6 1949
感动是毒
感动是毒 2020-12-10 04:58

I\'m trying to pass this selected radio button value from the razor view to the controller.... can someone please give me an idea how to do this?..................... My Vi

6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-10 05:14

    I saw this on another thread and it work like a champ.

    Razor view like this:

    @using (Html.BeginForm("test", "testcontroller"))
    {
      @Html.RadioButton("CashPayment", "1")Yes
      @Html.RadioButton("CashPayment", "0")No
    }
    

    And Controller like this:

    public ActionResult test(string CashPayment)
    {   
       //your code
    }
    

提交回复
热议问题