Shivaraj Poojary

Shivaraj Poojary

  • NA
  • 92
  • 315k

How to do Javascript confirm pop up with Yes or No option

Feb 10 2012 2:23 AM
Hi Experts..
I want to get Javascript Confirm popup with  Yes, No button instead of OK and Cancel and if Yes is pressed then I want to assign some value to it...please help me out..

Thanks in Advance.

Answers (2)

0
Shivaraj Poojary

Shivaraj Poojary

  • 0
  • 92
  • 315k
Feb 10 2012 3:12 AM
Thanks for your reply...Am getting it only in IE..In other browser it is coming  OK & Cancel button.
0
Satyapriya Nayak

Satyapriya Nayak

  • 0
  • 39.3k
  • 13.3m
Feb 10 2012 3:01 AM
Hi Shivaraj,


Try this...


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Save_multiple_select_item_dropdown.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
    <script language="javascript" type="text/javascript">
    function window.confirm(str)
    {
        execScript('n = msgbox("'+str+'","4132")', "vbscript");
        return(n == 6);
    }
</script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:Button ID="btnOk" runat="server" OnClientClick="javascript:return confirm('Are you sure to proceed?');" OnClick="btnOk_Click" Text="OK" />
    </div>
    </form>
</body>
</html>



using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace Save_multiple_select_item_dropdown
{
    public partial class WebForm1 : System.Web.UI.Page
    {
      
        protected void btnOk_Click(object sender, EventArgs e)
        {

        }
    }
}




Thanks