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

前端 未结 6 1940
感动是毒
感动是毒 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:09

    Use form collection

    [HttpPost]
        public ActionResult Index(FormCollection fc)
        {
    
          string answerA = fc["Answer1"];
          string answerB = fc["Answer2"];
          string answerC = fc["Answer3"];
          string answerD = fc["Answer4"];
          return View();
        }
    

提交回复
热议问题