将表单.aspx发布回mvc3中的控制器

时间:2013-02-13 12:39:32

标签: javascript asp.net-mvc-3 html5

我的.aspx:

   <% using (Html.BeginForm("SubmitDetails", "Recommend"))
      { %>
    <div class="clear"></div>
    <table>
      <tr>
        <td>
           <%: Html.LabelFor(model => Model.Firstname) %>
        </td>
        <td>
           <%: Html.TextBox("Firstname", String.Empty, new { maxlength = "80" })%>  
        </td>
      </tr>
      <tr>
        <td>
          <%: Html.LabelFor(model => Model.Surname) %>
        </td>
        <td>
          <%: Html.TextBox("Surname", String.Empty, new { maxlength = "80" })%>  
        </td>
      </tr>
      <tr>
        <td>
          <%: Html.LabelFor(model => Model.Email) %>
        </td>
        <td>
          <%: Html.TextBox("Email", String.Empty, new { maxlength = "80" })%>  
        </td>
      </tr>
    </table>
    <div class="actions-right"> 
      <a href="javascript:SubmitDetails();" class="button" id="post_button">Submit</a>
    </div>
    <% } %>

并且JS不知道该怎么做:

  function SubmitDetails() {
  var jqxhr = $.getJSON("<%= Url.Action("SubmitDetails", "Recommend", new { area = "User" }) %>", function (data) 
  {
    if (data.success)
    {

    }
  });

然后是控制器:

  [HttpPost]
    public JsonResult SubmitDetails()
    {
      RecommendedUserDataModel model = new RecommendedUserDataModel();
      model.Firstname = ;
      model.Surname = ;
      model.JobTitle = ;
      model.Email = ;
      model.Department = ;
      model.UserId = ;
      ZincService.SaveRecommendedUserDetails(model);

      return Json(new { success = true });

    }

    [HttpGet]
    public ActionResult SubmitDetails()
    {
      return RedirectToAction("Index");
    }

如果我传递参数列表中的所有值,它会有点长尾? 感谢

0 个答案:

没有答案