2009-10-11 3 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을 생성합니다.

관련 문제