I am using following code to change the language of HTML form on application page:

 <asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">

        <script type="text/javascript" src="/_layouts/SP.Core.js"></script>
        <script type="text/javascript" src="/_layouts/SP.Debug.js"></script>
        <script type="text/javascript" src="/_layouts/SP.Runtime.Debug.js"></script>

<script type="text/javascript">

    function ChangeLanguage(value) {
    var today = new Date();
    var oneYear = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000);
    var url = window.location.href;
    document.cookie = "lcid=" + value + ";path=/;expires=" + oneYear.toGMTString();
    window.location.href = url;


<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
// My Html form is here.. with 3 input type text and one input type submit button

<a href="#" onclick="javascript:ChangeLanguage(1053);">swedish</a>
<a href="javascript:ChangeLanguage(1033)">english</a>

When i click on any of the hyperlinks above, nothing happened. I could not understand, what is wrong? I am using two types of links, but neither works

  • I am not 100% sure but I don't think you need to take <form> tag in application page! Also put alert('function called'); in your JavaScript function to see if it is ever called... – Arsalan Adam Khatri Dec 17 '12 at 15:00
  • As i check by putting alert('function called'); in ChangeLanguage() JavaScript function, but it never called.. Also i check from outside of <form> tag, but did not work. – SPBeginer Dec 17 '12 at 15:29
  • Instead of placing <script> tag in "PlaceHolderAdditionalPageHead", place it inside "Main" without <form> – Arsalan Adam Khatri Dec 17 '12 at 15:32
  • Still did not work.....?? – SPBeginer Dec 17 '12 at 15:51
  • Make sure the script tag is included in the page, View source for the page to make sure! Also change function name from ChangeLanguage to customChangeLanguage – Arsalan Adam Khatri Dec 17 '12 at 15:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.