2009-10-11 6 views
0

VoirAjax.ActionLink, comment obtenir les données de formulaire à l'action du contrôleur

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

<% } %> 

Contrôleur

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

Répondre

2

Vous ne pouvez pas passer l'objet modèle. Cet argument attend les valeurs de route telles qu'un ID.

si vous passez Ajax.ActionLink("Create", "Create", new { id=23 }, ....

il va créer /create/23.

Questions connexes