Click here to Skip to main content
Click here to Skip to main content

Localizing JQuery Dialog Button

, 24 Jul 2012
Rate this:
Please Sign up or sign in to vote.
Localizing JQuery Dialog Button

Introduction

JQuery dialog box provides a way for the developers/designers to show useful information to the application users. Information to be shown in dialog is the content within DIV element. Content within the DIV can change based on the culture info. But, how do we change the text within the dialog buttons. This tip provides one of the ways to do it.

Using the Code

Value for the OK button is retrieved from the resource file and stored in a hidden variable.

<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Click" />
<asp:HiddenField ID="lblOK" runat="server" Value="<%$ Resources:Resource, OK %>">
</asp:HiddenField>
</div>
<div id="dialog">
Some information to the user through dialog
</div>
</form>

Text value of the button is initialized with the value of lblOK hidden variable.

<script language="javascript">
$(document).ready(function () {
okValue = $('#<%=lblOK.ClientID%>').val();
var $dialog = $('#dialog').dialog({ autoOpen: false, title: 'My Dialog', buttons: [
{
 text: okValue,
 click: function () { $(this).dialog("close"); }
}
]
});

$('#<%=Button1.ClientID%>').click(function () {
$dialog.dialog('open');
return false;
});
});
</script>

Points of Interest

This is just one of the ways of doing it. There could be multiple ways to do it and I would be interested in knowing any other way.

License

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

About the Author

Manjunath Shrikantiah
Architect
India India
9+ plus years of experience in IT industry. This includes experience in architecting, designing and developing solutions on Web and desktop application platforms

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 24 Jul 2012
Article Copyright 2012 by Manjunath Shrikantiah
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid