2009-10-11 70 views
0

查看Ajax.Actionlink,如何将表单数据到控制器的动作

<%= 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> 

<% } %> 

控制器

[AcceptVerbs(HttpVerbs.Post)] 
    public ActionResult Create(Customer info) 
    { 
     //INFO IS NULL??? 
     //WHAT IS THE PROBLEM? 
    } 

回答

2

您无法通过模型对象。该参数需要路由值,例如ID。

,如果你在Ajax.ActionLink("Create", "Create", new { id=23 }, ....

通过它将创建/create/23

相关问题