表格开始:
<% using (Html.BeginForm("Index", "recordssbook", FormMethod.Post, new { id = "SubmitForm" }))
{ %>
我要验证的提交按钮(同一表单中还有其他提交按钮):
<div><input type="submit" value="Delete Selected" id ="DeleteButton" name="DeleteButton" onclick="deleteRecordsDialog();"/></div>
我在 js 中的确认对话框中的按钮会自动返回 false:
function deleteRecordsDialog() {
var returnThis;
var numRecords = selectedRecordsArr.length;
document.getElementById("popupContainer");
var html = ""
html= html + '<table>';
html= html + '<tr>';
html= html + '<td class="warning-icon-cell"></td>';
html= html + '<td style="padding-left: 5px;">';
if (numAddresses == 1) {
html = html + '<p>You have chosen to delete a record.</p>';
}
else {
html = html + '<p>You have chosen to delete ' + numRecords + ' records.</p>';
}
html= html + '<p>Are you sure you wish to proceed?</p>';
html= html + '</td>';
html= html + '</tr>';
html = html + '</table>';
if (numAddresses == 1) {
html = html + '<div><input type="button" value="Yes, Delete Contact" style="width: 160px; onclick="document.DSubmitForm.HDeleteButton.submit(); CloseDialog();"/> <input type="button" value="Cancel" onclick="CloseDialog();"/></div>';
}
else {
html = html + '<div><input type="submit" value="Yes, Delete Contact(s)" style="width: 160px; onclick="document.DSubmitForm.HDeleteButton.submit(); CloseDialog();"/> <input type="button" value="Cancel" onclick="CloseDialog();"/></div>';
}
html = html + '</div>';
html = html + '</div>';
html = html + '</div>';
html = html + '</div>';
OpenDialog(html, 350, 180, false, "Delete Contact")
return false;
}
我的问题:
- 即使 onclick 返回 false,表单也已提交:我可以将输入类型更改为按钮而不是提交,如果我可以让伪提交工作,这应该可以工作
- _doPostBack 是另一种提交表单的方式吗?:从我的谷歌搜索中,我认为这应该模拟提交,但是当我将提交按钮设置为常规按钮时,如数字 1 中所述,单击“是,删除记录”不会提交表格。
- 我有多个提交按钮,这使得这更复杂
- 我不能使用 JQuery 的简单 .dialog
如果有人可以帮助我完成这项工作,我将不胜感激!
谢谢!!
编辑 所以html是一个带有按钮的记录列表,可以根据字母查询,添加记录,删除记录和编辑记录。所有这些按钮都是相同形式的提交按钮。
<td><input type="submit" value="ABC" name="SubmitButton"/></td>
<td><input type="submit" value="DEF" name="SubmitButton" /></td>
<td><input type="submit" value="GHI" name="SubmitButton" /></td>
<td><input type="submit" value="JKL" name="SubmitButton"/></td>
<td><input type="submit" value="MNO" name="SubmitButton"/></td>
<td><input type="submit" value="PQRS" name="SubmitButton" /></td>
<td><input type="submit" value="TUV" name="SubmitButton"/></td>
<td><input type="submit" value="WXYZ" name="SubmitButton" /></td>
<div><input type="button" value="Add Contact" id="addAddress" onclick="AddAddresDialog()" /></div>
<div><input type="button" value="View & Edit Selected" id="EditButton" name="EditButton" onclick="updateAddressDialog()"/></div>
<div><input type="submit" value="Delete Selected" id ="DeleteButton" name="SubmitButton" /></div>
我只想将确认对话框添加到单击的删除按钮中。我想使用一个自定义对话框窗口来确认它,该窗口是站点主控上的一个 div,它通过放置在覆盖整个屏幕的掩码顶部弹出,该掩码是在 deleteRecordsDialog() 中创建的。
我想要做的是将删除任务 (id="DeleteButton) 的提交按钮更改为仅打开由 deleteRecordsDialog() 创建的对话框而不是现在提交的表单的常规按钮。“是的,删除联系人( s)”自定义确认对话框中的按钮应该承担提交表单的任务,该任务的值是“删除选定的”,就像提交按钮现在所做的那样。