Vivek Thakur

Chaotically Complex

  Home  |   Contact  |   Syndication    |   Login
  105 Posts | 1 Stories | 504 Comments | 65 Trackbacks

News



Archives

ASP.NET Ventures

Monday, February 11, 2008 #

*******************
Note: view the updated entry below:

http://www.codeasp.net/blogs/vivek_iit/microsoft.net/129/javascript-popups-localization

*******************


We can localize Javascript pop up texts using server side variables in client side. In page class we will declare a protected variable:

public partial class _Default : BasePage
{
    protected string jsPopUpText;

    protected void Page_Load(object sender, EventArgs e)
    {
        jsPopUpText= Resources.TestSiteResources.jsPopUp;
    }


Then we will use this value in the client side JS code as:

<script language="javascript">
alert('<%= jsPopUpText %>');
</script>

This will show us the localized text value from the RESX file based on the current thread's locale. For more info on localization in ASP.NET, refer this article:

http://www.codeproject.com/KB/aspnet/localizationByVivekTakur.aspx