0

I'm trying to give language choice to my web site.I'm working in Asp.net and using <a> tag.I have to use JavaScript because, onclick event doesn't see code behind methods.But I don't know how call code behind method in script tag.Does anyone know about this?Please advice..

My code behind method:

protected void ConvertToEN(object sender, EventArgs e)
        {
            HttpCookie cookie = Request.Cookies["Lang"];
            if (cookie == null) cookie = new HttpCookie("Lang");
            cookie.Value = "en-US";
            Response.SetCookie(cookie);
            Response.Redirect("First_Page.aspx");
        } 

And these are <a> tags:

    <ul>
       <li><a id="translaterAZ">AZ</a></li>
       <li><a id="translaterRU">RU</a></li>
       <li><a id="translaterEN">EN</a></li>
   </ul>
fico
  • 9
  • 2
  • 8

1 Answers1

0

You could use a LinkButton.

<asp:LinkButton ID="MyLinkButton" runat="server" OnClick="ConvertToEN">EN</asp:LinkButton>

C#

protected void ConvertToEN(object sender, EventArgs e)
{
    HttpCookie cookie = Request.Cookies["Lang"];
    if (cookie == null) cookie = new HttpCookie("Lang");
    cookie.Value = "en-US";
    Response.SetCookie(cookie);
    Response.Redirect("First_Page.aspx");
}