查看
<%= Ajax.ActionLink("Create", "Create", ViewData.Model, new AjaxOptions { HttpMethod = "POST" })%>
<%= Html.ValidationSummary("Create was unsuccessful. Please correct the errors and try again.") %>
<% using (Ajax.BeginForm("Create", "Customer", ViewData.Model, new AjaxOptions { HttpMethod ="POST" }))
{%>
<fieldset>
<legend>Fields</legend>
<p>
<label for="Title">Title:</label>
<%= Html.TextBox("Name")%>
<%= Html.ValidationMessage("Name", "*")%>
</p>
<p>
<label for="Description">Description:</label>
<%= Html.TextArea("ContactNo")%>
<%= Html.ValidationMessage("Name", "*")%>
</p>
</fieldset>
<% } %>
<%= Html.ValidationSummary("Create was unsuccessful. Please correct the errors and try again.") %>
<% using (Ajax.BeginForm("Create", "Customer", ViewData.Model, new AjaxOptions { HttpMethod ="POST" }))
{%>
<fieldset>
<legend>Fields</legend>
<p>
<label for="Title">Title:</label>
<%= Html.TextBox("Name")%>
<%= Html.ValidationMessage("Name", "*")%>
</p>
<p>
<label for="Description">Description:</label>
<%= Html.TextArea("ContactNo")%>
<%= Html.ValidationMessage("Name", "*")%>
</p>
</fieldset>
<% } %>
控制器
答案 0 :(得分:2)
您无法传递模型对象。此参数需要路由值,例如ID。
如果您传入Ajax.ActionLink("Create", "Create", new { id=23 }, ....
它会创建/create/23
。