asp.net mvc radio button state

后端 未结 7 1888
轮回少年
轮回少年 2021-02-07 19:06

I\'m trying out asp.net mvc for a new project, and I ran across something odd. When I use the MVC UI helpers for textboxes, the values get persisted between calls. But, when I

7条回答
  •  [愿得一人]
    2021-02-07 19:13

    View:

    <%=Html.RadioButton("providerType","1")%>
    <%=Html.RadioButton("providerType","2")%>
    <%=Html.RadioButton("providerType","3")%>
    

    Controller:

    public ActionResult GetType(FormCollection collection)
    {
     string type=collection.Get("providerType");
    
      if(type=="1")
       //code
      else if(type=="2")
       //code
      else
       //code
    
     return View();
    }
    

提交回复
热议问题