如何将c1,c2和c3的值插入@ Url.Action [英] How do I insert the values for c1,c2 and c3 into the @Url.Action
本文介绍了如何将c1,c2和c3的值插入@ Url.Action的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在MVC5中如何将c1,c2和c3的值插入@ Url.Action?
@ Html.TextBox(c1)
@ Html.TextBox(c2)
@ Html.TextBox(c3)
< 表格 action = @ Url.Action( AddAction, new { col1 = c1,col2 = c2,col3 = c3 }) 方法 = post > < input 类型 = submit id = AddTo value = 添加到 / > < / form
解决方案
这里有一个简单的语法错误...
< 表格action = @ Url.Action( AddAction, new { col1 = c1,col2 = c2,col3 = c3 }) > < / form >
您应该这样写...
< 表格 action = < span class = code-pagedirective><%:@ Url.Action( AddAction, new {col1 = c1,col2 = c2,col3 = c3})%> > < / form >
但MVC有一个帮助方法以更好的方式创建表单...
@ using (Html.BeginForm(ControllerName,ActionName,new {parameter-list},FormMethod.Post))
{
}
在此处查看更多信息: http:/ /msdn.microsoft.com/en-us/library/system.web.mvc.html.formextensions.beginform(v=vs.118).aspx [ ^ ]
In MVC5 how do I insert the values for c1,c2 and c3 into the @Url.Action?
@Html.TextBox("c1")
@Html.TextBox("c2")
@Html.TextBox("c3")
<form action="@Url.Action("AddAction", new { col1=c1,col2=c2,col3=c3 })" method="post"><input type="submit" id="AddTo" value="Add To" /></form
解决方案
You have a simple syntax error here...
<form action="@Url.Action("AddAction", new { col1=c1,col2=c2,col3=c3 })"></form>
You should write it like this...
<form action="<%: @Url.Action("AddAction", new { col1=c1,col2=c2,col3=c3 }) %>"></form>
But MVC has a helper method to create forms in a better way...
@using (Html.BeginForm("ControllerName", "ActionName", new {parameter-list}, FormMethod.Post )) { }
See more here: http://msdn.microsoft.com/en-us/library/system.web.mvc.html.formextensions.beginform(v=vs.118).aspx[^]
这篇关于如何将c1,c2和c3的值插入@ Url.Action的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文