我有一個局部視圖,它有兩個按鈕並與模型綁定(由GET請求 - /用戶/編輯/ 1生成)。我已經使用BeginForm,沒有指定任何操作名稱,因爲我想使用模型驗證。我已經使用ajax配置將操作(URL)分配給「關閉」按鈕。當我運行我的應用程序並按下關閉按鈕時,首先,它使用ajax配置(關閉數據輸入)成功執行操作,然後對POST請求(/ User/Edit/1)執行操作。我想知道,爲什麼當我按下關閉按鈕時執行第二個動作,我該如何停止執行?MVC3:帶ajax調用的多個按鈕
管窺:_Record.cshtml
@using(Html.BeginForm())
{
<hr />
<p>
<fieldset style="display:inline-block">
<legend>User</legend>
<table border="1">
<tr>
<th style="text-align: right; padding-left: 20px;">
@Html.LabelFor(model => model.first_name)
</th>
<td>
<div class="editor-field">
@Html.TextBoxFor(model => model.first_name,
new { style = "width:270px;", maxlength = 30 })
@Html.ValidationMessageFor(model => model.first_name)
</div>
</td>
</tr>
*****
*****
<p>
<input type="submit" value="Save" style="float: right" />
<input type="submit" value="Close" onclick="Close()" style="float: right" />
?</p>
</fieldset>
@Html.ValidationSummary(true)
</p>
}
你有沒有通過與Visual Studio的調試器的代碼?如果我們能看到控制器,它也可以幫助我們。 – northben 2013-04-08 17:49:28