4
        <form action="@Url.Action("PokemonSteps", "PokemonView", new { id = Model.Id, steps = steps })">
            <input type="number" name="steps" min="1" max="@Model.userSteps">
            <input type="submit">
        </form>

This form is a number box from 1 to the amount of steps the user has. When they submit the number in the box, I want to pass it to @Url.Action as the steps in the steps = steps part.

How do I go about that (sorry for the really stupid question)

1
  • Not clear what your asking. You should not have new { steps = steps } - you have a form control named steps and the value of that control will be posted when you submit the form Commented Jun 2, 2017 at 9:53

2 Answers 2

4
<form action="@Url.Action("PokemonSteps", "PokemonView")" method="post">
   <input type="hidden" name="id" value="@Model.Id">
   <input type="number" name="steps" min="1" max="@Model.userSteps">
   <input type="submit" value="Submit">
</form>

Please add Attribute method="post" and share your controller method signature also...

Sign up to request clarification or add additional context in comments.

1 Comment

that was enough for me to understand what I was doing wrong, thank you Also adding HttpPost to my controller method and it's perfect
2

Try doing something like this:

@using (Html.BeginForm("PokemonSteps", "PokemonView", FormMethod.Post)){    
     @Html.TextBoxFor(m=> m.userSteps)
     <input type="submit" value="Submit" />
}

Hope this Helps!!

Comments

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.