Vivek Thakur

Chaotically Complex

  Home  |   Contact  |   Syndication    |   Login
  102 Posts | 1 Stories | 256 Comments | 66 Trackbacks

News



Archives

Monday, February 11, 2008 #

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