title: Call Javascript Click event of HTML Control from C# Code Behind
body: <p>I am working in asp.net c#. I have a master page that has HTML anchor tag that changes the culture of website, when clicked.</p>
  
  <pre><code>&lt;a id="LinkLanguage" runat="server" href="javascript:void(0)"&gt;&lt;asp:Literal ID="langltrl" runat="server" Text="&lt;%$ Resources:skin, Français %&gt;" /&gt;&lt;/a&gt; 
  </code></pre>
  
  <p>To handle the click event, I am doing the following way:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;     
      $("#LinkLanguage").click(function (e) {     
          e.preventDefault();     
              $.ajax({        
              type: "POST",       
              url: "Default.aspx/LinkLanguage_Click",     
              contentType: 'application/json;charset=utf-8',      
              dataType:'json',        
              success: function () { location.reload(); },        
              error: function (xhr, ajaxOptions, thrownError) {       
                  alert(xhr.status);      
                  alert(xhr.responseText);        
                  alert(thrownError);     
              }       
          });     
      });     
  
  &lt;/script&gt;
  </code></pre>
  
  <p>and the web method (Default.aspx/LinkLanguage_Click) that is being called to change the culture language is working in the following way:</p>
  
  <pre><code>if (HttpContext.Current.Session["application.language"] != null)
          {
              if (HttpContext.Current.Session["application.language"].ToString() == "en-CA")
              {
                  HttpContext.Current.Session["application.language"] = "fr-CA";
              }
              else
              {
                  HttpContext.Current.Session["application.language"] = "en-CA";
              }
          }
  }
  </code></pre>
  
  <p>Now, my question is on one of the content pages, I want to change the language based on the conditions. How can I call the language change anchor tag's(LinkLanguage) click event?</p>
  
  <p>Following code is in content page:</p>
  
  <pre><code>if (Request.QueryString["Language"] == "FR")
  {
     // Want to change language here
  }
  </code></pre>
  
  <p>If I just assign session here i.e,</p>
  
  <pre><code>HttpContext.Current.Session["application.language"] = "fr-CA";
  </code></pre>
  
  <p>It needs a refresh, if I do response.redirect() to reload the page, it gives error page redirected too many time.</p>
  
  <p>How can I make it work, Please help. Thanks</p>