ASP 提交按钮单击/_doPostBack
ASP Submit Button onclick/_doPostBack
表单开始:
<% 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((创建的对话框,而不是现在执行的表单提交。自定义确认对话框中的"是,删除联系人"按钮应承担提交值为"删除所选"的表单的任务,就像现在的提交按钮一样。
如果没有你的html,很难真正理解你想做什么。但是,您可以尝试以下操作:
HTML:
<div>
<input type="submit" value="Delete Selected" id ="DeleteButton" name="DeleteButton" onclick="deleteRecordsDialog();"/>
<input type="button" id ="DeleteButtonSubmit" name="DeleteButtonSubmit" style="display:none;" />
</div>
贾夫文:
要为模态创建按钮:
html = html + '<div><input type="button" value="Yes, Delete Contact(s)" style="width: 160px; onclick="deleteContact();"/> <input type="button" value="Cancel" onclick="CloseDialog();"/></div>';
发布删除确认的功能:
function deleteContact()
{
document.getElementById('DeleteButtonSubmit').click();
}
此函数将单击用户最初单击的按钮下方的隐藏按钮。 如果您正确设置了此按钮,则表单应包含您需要的所有信息。
相关文章:
- 使用clickToggle并在单击另一个元素时关闭元素
- 单击时将焦点更改为元素
- 单击F5时如何停止页面加载
- 通过单击表单中的按钮,在代码生成中使用javascript生成字母数字代码
- 在单击任何位置时隐藏元素,而不检查每次DOM单击
- 单击jquery清除输入值
- 单击按钮以等待单击按钮
- 在单击href链接的同时下载文件
- 单击顶部导航时如何进行向下滚动效果(向下滑动).
- 使图像在单击时展开到不大于浏览器
- 单击按钮后如何逐个调用分区,上一个分区将隐藏
- 如何在单击复选框后调用控制器方法
- 单击页面上的链接后高度发生变化
- 使用jquery在单击时在单元格中输入值
- 将纯文本URL转换为可单击链接
- ASP.NET通过单击JavaScript按钮触发c#事件
- 单击更改图标并通过javascript添加一个css类
- 阻止在select2单击时调用ajax
- 复制图像路径以单击它
- __从javascript渲染html时的doPostBack触发器(在真正单击之前)