0
我在mvc3中使用Ajax表單。表單提交後在「OnSuccess」函數中獲取按鈕ID
以下是代碼。
<% using (Ajax.BeginForm("Method", "Conroller", new AjaxOptions
{
UpdateTargetId = "PopupBody",
HttpMethod = "post",
OnSuccess = "OnSuccessContactInfoSave"
}, new { @id = "frmContactInfo" }))
{ %>
function OnSuccessContactInfoSave(data, textStatus) {
alert('completed with success.');
}
現在,我有一個頁面上的2個按鈕是提交按鈕,另一個是普通按鈕。 現在,我想知道Onsuccess功能中的點擊按鈕。
我該如何獲得它在「OnSuccessContactInfoSave」功能?
由於提前
編輯:
這是我的看法
<% using (Ajax.BeginForm("SaveContactInfo", "ManageUser", new AjaxOptions
{
UpdateTargetId = "PopupBody",
HttpMethod = "Post"
}))
{ %> <div class="ciMain">
<input type="submit" id="btnSaveAndClose" name="btn" value="Save" />
<input type="submit" value="Save and continue to next step" name="btn" />
<input type="button" value="Cancel" />
</div>
<% } %>
這是控制器
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult SaveContactInfo(FormCollection userViewModel, ContactInfoViewModel model, string btn)
{
//string test = Request["btn"].ToString();
try
{
return View("ContactInfo", model);
}
catch (Exception)
{
return View("ContactInfo", model);
}
}
我試着用這個:http://stackoverflow.com/a/14980550/1752787 –
但是,獲取請求[「btn」] == null,在這一行:Response.AppendHeader(「X-Button」,Request [ 「BTN」]); –
上午我錯過了什麼? –