MVC ASP.NET Url.Action在表单action中传递数据 [英] MVC ASP.NET Url.Action in form action, passing it form data
本文介绍了MVC ASP.NET Url.Action在表单action中传递数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< form action =@ Url.Action(PokemonSteps,PokemonView,new {id = Model.Id,steps = steps})>
< input type =numbername =stepsmin =1max =@ Model.userSteps>
< input type =submit>
< / form>
此表单是一个从1到用户拥有的步数的数字框。
当他们在框中提交数字时,我想将它作为步骤传递给
@ Url.Action
c>在 steps = steps
部分中。
我该如何解决这个问题(抱歉,真的很愚蠢的问题)
解决方案
< form action =@ Url.Action(PokemonSteps, PokemonView)method =post>
< input type =hiddenname =idvalue =@ Model.Id>
< input type =numbername =stepsmin =1max =@ Model.userSteps>
< input type =submitvalue =提交>
< / form>
请添加Attribute method =post并共享您的控制器方法签名也... ...
<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)
解决方案
<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...
这篇关于MVC ASP.NET Url.Action在表单action中传递数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文