【发布时间】:2014-07-29 02:34:31
【问题描述】:
//Model
public class Car
{
string name{get;set;}
double speed {get;set;}
//etc.
}
基本模型
//Controller
public ActionResult ModifyCar(Car c)
{
c = GetAdditionalData(c.name, c.speed);
return View(c);
}
所以我正在致电外部服务以获取更多汽车数据。
下面是我真的很困惑的表格。我只是要用 HTML 来写这个。
但是从这里我想采用一个基本的空模型..填充它然后发送到控制器以获取更多数据。
//View
@model Car
<form id="carform" method="post" action="/Car/ModifyCar"> //Guessing
<input id="carName" /> //Somehow bind with @model.name
<input id="carSpeed" /> //Somehow bind with @model.speed
<input type="submit" /> //Somehow send the model to the controller
</form>
抱歉,我对视图部分不太擅长,但我希望你能看到我在这里的目标。
另外,我正在进行需要表单 ID 的验证。我注意到使用 HTML Helper 制作表单时没有表单 ID。那会破坏我写的CSS。
任何帮助将不胜感激。
谢谢
【问题讨论】:
标签: forms asp.net-mvc-4 post view model