YES OR NO MessageBox

How to display a confirmation window before deleting entries? The buttons must be YES or NO . Not OK or CANCEL . I have this code, but it only works for C # winforms ...

 if (MessageBox.Show("Delete record no. " + numID.Text + "?", "Confirm User Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { //codes to delete records } 
+4
source share
2 answers

If you show this client side, you should use Javascript. A good way to do this is to use the jQuery dialog method. For instance:

Markup:

 <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/

+1
source
 <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script type = "text/javascript"> function Confirm() { var confirm_value = document.createElement("INPUT"); confirm_value.type = "hidden"; confirm_value.name = "confirm_value"; if (confirm("Do you want to save data?")) { confirm_value.value = "Yes"; } else { confirm_value.value = "No"; } document.forms[0].appendChild(confirm_value); } </script> </head> <body> <form id="form1" runat="server"> <asp:Button ID="btnConfirm" runat="server" OnClick = "OnConfirm" Text = "Raise Confirm" OnClientClick = "Confirm()"/> </form> </body> </html> 

Check out this link:

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

+1
source

All Articles