与Ajax.ActionLink邮政表单字段 [英] Post form fields with Ajax.ActionLink

查看:144
本文介绍了与Ajax.ActionLink邮政表单字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个观点我在MVC 3应用程序,允许用户输入送货地址和下订单。表单字段,我展示在视图中完全一样的用户配置文件字段。所以,我要考虑一个链接,用户可以保存他们已经进入了他们的个人资料过于数据。字段,如姓氏,姓名,地址等。
我想用Ajax.ActionLink,但问题是我不知道如何发送表单字段,节省了数据操作。我拥有的是:

I have a View in my MVC 3 application that lets the user enter the shipping address and place the order. The form fields that I show on the view are exactly the same as user profile fields. So I want to consider a link for the user to save the data they have entered into their profile too. Fields like first name, last name, address and so on. I want to use Ajax.ActionLink, but the problem is I don't know how to send the form fields to the Action that saves the data. What I have is:

@ Ajax.ActionLink(保存到个人资料,SaveAccountProfile,新的{地址= ????},新AjaxOptions {列举HTTPMethod =POST,InsertionMode = InsertionMode.Replace,的onSuccess =警告(帐户的个人资料已成功更新。')})

我会发布什么作为路由数据?

What would I post as the route data?

推荐答案

您应该在这种情况下使用 Ajax.BeginForm 。这样,表单字段值将被自动发送到服务器。

You should use an Ajax.BeginForm in this case. This way form field values will automatically be posted to the server.

@using (Ajax.BeginForm("SaveAccountProfile", new AjaxOptions { HttpMethod = "POST", InsertionMode = InsertionMode.Replace, OnSuccess = "alert('Account profile was successfully updated.')" }))
{
    ... some input fields
    <input type="submit" value="Save into profile" />   
}

这篇关于与Ajax.ActionLink邮政表单字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆