如何在删除记录前显示确认消息框?按钮只能是 YES
或 NO
。不是 OK
或 CANCEL
。我有这段代码,但它只适用于 c# winforms...
if (MessageBox.Show("Delete record no. " + numID.Text + "?", "Confirm User Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
//codes to delete records
}
如果您要显示此客户端,则应使用 Javascript。执行此操作的一个好方法是使用 jQuery dialog方法。例如:
标记:
<div id="dialog-confirm">This is the content</div>
Javascript:
$( "#dialog-confirm" ).dialog({
resizable: false,
height:280,
modal: true,
buttons: {
"Yes": function() {
$( this ).dialog( "close" );
},
"No": function() {
$( this ).dialog( "close" );
}
}
});
fiddle :http://jsfiddle.net/ghLpV/