<form action="/Villa/Add" method="post">
<table>
<tr>
<td>
Name:
</td>
<td>
<%= Html.TextBox("name") %>
<%= Html.ValidationMessage("Name") %>
</td>
</tr>
<tr>
<td>
</td>
<td>
<input type="submit" value="Add" />
</td>
</tr>
</table>
</form>
Run Code Online (Sandbox Code Playgroud)
我的表单在上面,如何检索控制器中的值?
非常感谢提前!很难找到合适的材料,因为MVC的不同预览被发布和不同.
tva*_*son 21
这适用于ASP.Net MVC Beta.
public ActionResult Add( string name ) {
....
}
or
public ActionResult Add( FormCollection form ) {
string name = form["Name"];
}
or
public ActionResult Add( [Bind(Prefix="")]Villa villa ) {
villa.Name ...
}
Run Code Online (Sandbox Code Playgroud)
你尝试过这样的事吗?伪...
public class VillaController : Controller
{
public ActionResult Add(string name)
{
// Code...
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
34982 次 |
| 最近记录: |