Jquery BlockUI w/Asp.net确认删除
Asp.NET3.5/WebForms(无ajax) 我正在尝试用jquery&UIBlock更新删除确认框。旧代码看起来像这样Jquery BlockUI w/Asp.net确认删除,asp.net,jquery,Asp.net,Jquery,Asp.NET3.5/WebForms(无ajax) 我正在尝试用jquery&UIBlock更新删除确认框。旧代码看起来像这样 <asp:LinkButton OnClientClick="return confirm('Are you sure you want to delete?')" runat="server" ID="DeleteButton" OnClick="DeleteButton_OnClick">Delete</asp:LinkButton> )
<asp:LinkButton OnClientClick="return confirm('Are you sure you want to delete?')" runat="server" ID="DeleteButton" OnClick="DeleteButton_OnClick">Delete</asp:LinkButton>
)有一些带有UIBlock的示例,但没有一个使用UIBlock作为确认/模式弹出窗口
谢谢你的帮助/指点
回答
<a href="#" id="delete">
<span>Delete?</span>
</a>
<div id="question" style="display:none; cursor: default">
<h1>Are you sure you want to delete?</h1>
<asp:LinkButton runat="server" Text="Yes" OnClick="DeleteButton_OnClick"></asp:LinkButton>
<a href="#" id="no"><span>No</span></a>
</div>
<script type="text/javascript">
$(document).ready(function() {
$('#delete').click(function(ev) {
ev.preventDefault();
$.blockUI({ message: $('#question'), css: { width: '275px'} });
});
$('#no').click(function() {
$.unblockUI();
return false;
});
});
</script>
您确定要删除吗?
$(文档).ready(函数(){
$(“#删除”)。单击(函数(ev){
ev.preventDefault();
$.blockUI({message:$('#question'),css:{width:'275px'}});
});
$('#否')。单击(函数(){
$.unbui();
返回false;
});
});
您可以执行以下操作:
$('#DeleteButton').bind('click', function() {
// if confirmation button inside the form is pressed ..
$('#confirm_button').bind('click', function() {
// redirect to the page where it resolves the request
window.location = "http://www.site.com/?delete";
// or use ajax call
$.ajax({
// the request to delete
});
// this one in case you choose to make ajax request
$.unblockUI();
});
$.blockUI({
// form setted with display:none; in css to be trigged when delete button is clicked
// css here is an example
message: $('#delete_form'),
css: {
border: 'none',
padding: '15px',
width: '400px',
backgroundColor: '#000',
'-webkit-border-radius': '10px',
'-moz-border-radius': '10px',
color: '#fff'
}
});
// cancel button inside the form, when clicked, dismiss form
$('#cancel').click($.unblockUI);
// if user clicks outside the form, it dismisses the form as well
$('.blockOverlay').click($.unblockUI);
});
我使用的是标准的web表单,没有ajax或rest服务。请注意答案。。这个例子也很简单。@yoda,也许我不理解这个例子。如何在blockui>confirm之后回调以完成删除操作?这就是我的想法。问题是我没有管理删除的页面,也没有任何rest服务。我只想继续启动回发,以便在页面的方法中处理删除操作。经过进一步的挖掘,我想我需要的是“Page.ClientScript.GetPostBackEventReference”,我明天将在@work上尝试它。我现在得到了它……愚蠢的我试图让它比需要的更复杂。可见显示按钮只是一个标准的html按钮。确认中的按钮是asp.net链接按钮,因此当单击“删除是”时,会发生回发。