Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5969911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:17:54+00:00 2026-05-22T20:17:54+00:00

I have a Visual Studio C# .NET project. I have two master templates. One

  • 0

I have a Visual Studio C# .NET project. I have two master templates. One for the original website in english. And a second master page for the Spanish version of the website.
In both master pages, there’s a link that says “English” (or Spanish). This link will take the user to the translation of the website in the other language.

But If I am in the “About Us” page in english, and I click in the SPANISH link, it will take me to the Home Page in spanish and not to the current page (in this case About Us) in spanish. How can I set the Link in the master page, to know what page translation i want ?

I have no idea how to code this thing.

Thanks.

SOLUTION – SOLVED

<script type="text/javascript">
        function SetLanguageLinkUrl() {
            var url = location.href;
            var newURL;

         // Create block of these, for each set of pages in different languages.
                if (url.indexOf("inicio") > 0)
                newURL = url.replace("/es/inicio.aspx", "/en/index.aspx");
                else if (url.indexOf("index") > 0)
                    newURL = url.replace("/en/index.aspx", "/es/inicio.aspx");

        // The Redirect
            window.location = newURL;

    }
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T20:17:55+00:00Added an answer on May 22, 2026 at 8:17 pm

    Assuming you have an HtmlAnchor in your masterpage, you could replace the language folder in the link with the other language folder in your url.

    void SetLanguageLinkUrl()
    {
         string url = Request.Url.PathAndQuery.ToString().ToLowerInvariant();
         if(url.StartsWith("/en/"))
             languageLink.HRef = url.Replace("/en/", "/es/");
         else if(url.StartsWith("/es/"))
             languageLink.HRef = url.Replace("/es/", "/en/");
    }
    

    UPDATE

    If you want to translate the url, you’re maybe best having a dictionary of urls to use as a lookup table.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I have two project in a .NET 4.0 framework visual studio solution. First
I have a visual studio 2008 solution that includes an asp.net-hosted remoting project in
In visual studio, I have an asp.net 3.5 project that is using MS Enterprise
I am writing a website with Visual Studio 2008 and ASP.NET 3.5. I have
I have two versions of a project. One for Silverlight and one for .NET.
I have C# .net project with SQL Server 2008 written in Visual Studio 2008.
I have a problem with a C# ASP .NET project in Visual Studio 2008
I have a solution of mixed VB.NET and C++ projects. When using Visual Studio
Does Visual Studio .NET have a way to toggle word-wrap on and off? I
I have a Visual Studio 2005 solution (.sln) with a mix of .NET and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.