是或否MessageBox

如何在删除记录之前显示确认消息框? 按钮应为YESNO 。 不行或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 对话框方法。 例如:

标记:

 
This is the content

使用Javascript:

  $( "#dialog-confirm" ).dialog({ resizable: false, height:280, modal: true, buttons: { "Yes": function() { $( this ).dialog( "close" ); }, "No": function() { $( this ).dialog( "close" ); } } }); 

小提琴: http : //jsfiddle.net/ghLpV/

       

检查此链接:

http://aspsnippets.com/Articles/Server-Side-Code-Behind-Yes-No-Confirmation-Message-Box-in-ASPNet.aspx