0

I've got this in a View:

<form method="post" action="../MasterData/SaveRoad">
...
<input type="text" name="description" maxlength="100">
@Html.DropDownList("concessions")
...

And in a controller, this:

public ActionResult SaveRoad()
{
    string description = Request["description"].ToString();
    // code to get the dropdownlist selected value??
...

Now, I'm getting the description using the Request but how can I get the selected value of the dropdownlist?

1 Answer 1

1

Doing Request["description"] is somewhat against the nature of ASP.NET MVC. Please don't. Rather declare this and the other input you have (dropdown) as parameters of the action:

public ActionResult SaveRoad(string description, string concessions)
Sign up to request clarification or add additional context in comments.

1 Comment

Man, I didn't know that the action of the form would take as parameters the inputs it contains and that to access them you'd only need to write their names in the parameters of the ActionResult. I've been using Request all over. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.