ASP.NET - Get selected Dropdownlist value from my Controller

Asked

Viewed 30 times

0

I have a dropdownlist that is set in my view as follows:

 @Html.DropDownList("Exame", ViewBag.Exame as SelectList, "Escolha uma
 opção...", new { @class = "form-control", @name="ExameARegistar" })

This dropdownlist should allow a registered user to register for an exam from a list. To do this, I will need to get the selected value from my controller.

I tried to use the Request.Form["ExameARegistar"] but it always returns null. I would like to understand what is causing this error. Otherwise, I would like to know if there is a better alternative to Request.Form...

  • Already rents Form["Exame"], which is defined in DropDownList?

  • Request.Form["Exam"]? Yes, I have tried. And the same happens...

  • Tried to pass as parameter in Action, public ActionResult SuaAction(string ExameARegistar)?

  • @Barbetta not yet. I will try. How do I pass the selected value as input argument on the Submit button? This is my button already now: <input type="Submit" value="Add Exam" class="btn btn-default" onclick="Location.href='@Url.Action("Add Review", "Applications")' " />

  • You are using ASP.NET MVC or Webforms?

1 answer

-1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.