我正在开发ASP.NET MVC应用程序。我对ASP.NET MVC很陌生。我目前正在保存数据。出于这个原因,如果记录已经存在,我需要预先填充一个表单。我控制器目前看起来是这样的:在ASP.NET MVC中更新数据之后更新视图
public ActionResult Edit(int productId)
{
Product product = Product.FindById(productId);
return View();
}
我对这个动作观点是这样的:
<div class="row">
<div class="col-md-6">
<h3>Product</h3>
<div class="form-group">
<label class="control-label" for="productName">Product Name</label>
<input type="text" class="form-control" id="productName" name="productName" />
</div>
</div>
</div>
我不想使用内置的HTML辅助。但是,我试图找出如何将product.Name
的值存入名为productName
的文本框中。我如何在不使用HTML助手的情况下在MVC中执行此操作?
谢谢!
不知道您打算如何展示产品因为你没有将产品传递给视图?如果您不想使用助手,则可以使用可以作为模型传递给视图的产品,直接在输入的值属性中传递产品名称... – AndreiC 2014-09-30 13:30:39