mrbengi mrbengi - 9 months ago 28
ASP.NET (C#) Question

Yes or No buttons on confirmation box

Below code runs a confirmation box with Javascript on Asp.Net.

I need to change the button texts. How can I use Yes or No buttons with this messagebox?


<html xmlns="">
<head runat="server">
<script type="text/javascript">
function ConfirmOnDelete() {
if (confirm("Some question") == true)
return true;
return false;
<form id="form1" runat="server">
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return ConfirmOnDelete();" OnClick="Button1_Click"/>

Answer Source

You can't do this with confirm. There is no way to customize the buttons of the native alert/confirm/etc dialogs.

You could make a DOM-based dialog instead, and customize the elements to your liking.