Click here to Skip to main content
15,891,951 members
Articles / Web Development / ASP.NET

jQuery Localized Confirmation Box

Rate me:
Please Sign up or sign in to vote.
3.00/5 (3 votes)
13 Jul 2012CPOL 12.9K   1   3
A localized confirmation box in jQuery

We were facing an issue that our French customers wanted a confirm box with button captions in French, i.e., they wanted OK/Cancel captions in French. We had tried so much on Internet Explorer and some other crap in other browsers. But we finally found a solution.

jQuery Easy Confirm Dialog Plug in

This is very simple and all we need is a stylesheet and jquery-ui.js.

The code is given below.

HTML Page Codes

XML
<head runat="server">
    <title></title>
       <link href="Styles/EasyConfirm.css" 
       rel="stylesheet" type="text/css" />
    <script src="Scripts/jquery-1.7.js" 
    type="text/javascript"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js" 
     type="text/javascript"></script>
    
     <script src="Scripts/jquery.easy-confirm-dialog.js" 
     type="text/javascript"></script>
  </head>

 <asp:Button ID="ClickBtn" runat="server" 
 Text="Click" OnClick="ClickBtn_Click" />
    <a href="#" id="yesno">Normal test with yes and no</a>
    <script type="text/javascript">
        $("#<%=ClickBtn.ClientID %>").easyconfirm
        ({ locale: { title: '<%=TitleFor %>', 
               text: '<%=Message %>', 
               button: ['<%=CancelButton %>', '<%=OkButton %>']} });

        $("#<%=ClickBtn.ClientID %>").click(function () {           
                alert("You clicked yes");           
        }); 

The Code Behind

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class _Default : System.Web.UI.Page
    {
        public string TitleFor
        {
            get;
            set;
        }

        public string Message
        {
            get;
            set;
        }

        public string OkButton
        {
            get;
            set;
        }

        public string CancelButton
        {
            get;
            set;
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            TitleFor = "Please Confirm";
            Message = "Do you agree ?";
            OkButton = "bonjour/ok";
            CancelButton = "Bonjour/Cancel";
        }

        protected void ClickBtn_Click(object sender, EventArgs e)
        {
  
        }
    }
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
India India
I am a software developer with a passion to develop innovative ideas.

Comments and Discussions

 
GeneralMy vote of 1 Pin
fjdiewornncalwe6-Sep-12 3:29
professionalfjdiewornncalwe6-Sep-12 3:29 
QuestionMy Blog Pin
Christopher John Paul22-Jul-12 20:51
Christopher John Paul22-Jul-12 20:51 
AnswerFormating Pin
Clifford Nelson12-Jul-12 13:37
Clifford Nelson12-Jul-12 13:37 
Your code does not have the right tag for code

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.