Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

LinkButton PostBack Language Problem


Hi Episerver,

I'm having a problem where I'm using a LinkButton control which does a Postback from one language but returns the page back in another.

For example, if I'm on and I do a postback on the page with a link button, I will return back to instead of the German page I was expecting. I've tried using UserInterfaceLanguage.Instance and ContentLanguage.Instance to set the correct language on PreInit but none of these have the desired effect.

Can anyone help out?

Kind Regards,


Jul 07, 2008 12:36


This is a little bit tricky but not impossible.

The problem is related to LinkUrl, which I guess you use. It does not look at the its own PageData.LanguageBranch property to calculate the URL. Instead it will use ContentLanguage.PreferredCulture for some strange reason.

//LinkURL uses PreferredCulture to calculate it's value and we have to change it manually before reading it.
currentPreferredCulture = ContentLanguage.PreferredCulture;
if (string.Compare(page.LanguageBranch, ContentLanguage.PreferredCulture.Name, StringComparison.OrdinalIgnoreCase) != 0)
ContentLanguage.PreferredCulture = CultureInfo.GetCultureInfo(page.LanguageBranch);
YourLink.NavigateUrl = page.LinkURL;
ContentLanguage.PreferredCulture = currentPredderedCulture;

Another way to do it is to add the language yourself. This looks easier but has side effects because it does not consider you settings in the siteHosts tag.

UriSupport.AddLanguageSelection(page.StaticLinkUrl, page.LanguageBranch);


Jul 07, 2008 13:57

I think this might be useful for something else actually, however I'm just using a OnClick event for the LinkButton control so there's no LinkUrls being used. I've tried setting the preferred language on the Click event and on page preinit but this still changes the URL from de to en.

As mentioned before, the LinkURL trick above will be useful so thank you for sharing that,


Jul 07, 2008 15:02

Ah, I just found out my problem. The Form action for the /de/page was set to point to /en/page. This was because I have Language Fallback on. So I was trying to go to a page which hadn't been created yet, so it was falling back to the default language page which had been created.

Thanks Fredrik for the help, I'm sure I will be using that code in the future.


Jul 07, 2008 16:01
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.