locked
how to pass radiobuton value from view to controller RRS feed

  • Question

  • User1928394251 posted

    hello . my view :

    @using (Html.BeginForm("index4", "afishstudio", FormMethod.Post, null))
    {
    <h5> مدیرکل: @Html.RadioButton("modiran_semat", "modirkol") </h5>
    <h5> قایم مقام: @Html.RadioButton("modiran_semat", "ghaemmagham") </h5>
    <h5> معاون خبر: @Html.RadioButton("modiran_semat", "moaven_khabar") </h5>
    <h5> معاون فنی: @Html.RadioButton("modiran_semat", "moaven-fani") </h5>
    <h5>معاون سیما: @Html.RadioButton("modiran_semat", "moaven-sima") </h5>
    <h5> معاون صدا: @Html.RadioButton("modiran_semat", "moaven-seda") </h5>
    <input type="submit" id="submit" name="submit" value="click" />
    }

    i dont know how must pass values to controller and then show another view .

    thanks

    Monday, December 24, 2018 9:41 AM

Answers

  • User1724605321 posted

    Hi aabedeni056 ,

    You can refer to the following code to get the radio value in controller :

    [HttpPost]
    public ActionResult index4(string modiran_semat)
    {
          
           return View();
    }
    

    Best Regards,

    Nan Yu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, December 25, 2018 2:53 AM

All replies

  • User1724605321 posted

    Hi aabedeni056 ,

    You can refer to the following code to get the radio value in controller :

    [HttpPost]
    public ActionResult index4(string modiran_semat)
    {
          
           return View();
    }
    

    Best Regards,

    Nan Yu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, December 25, 2018 2:53 AM
  • User1928394251 posted

    thank uou very much .

    i pass to controller(save in table )  .my controller is :

    public ActionResult index4(string modiran_semat, modiran modiran)
    {

    TryUpdateModel(modiran, modiran_semat);
    if (ModelState.IsValid)
    {
    db.modiran.Add(modiran);
    db.SaveChanges();
    return RedirectToAction("index5");
    }

    return View();
    }

    my question : how to show in new view :name with semat?

    Tuesday, December 25, 2018 7:04 AM