November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
I think you can use html.translate for multiple languages. And just put xpath in language xml files.
Ok i think you missed the point. It has nothing to do with localization/translation.
Html.BeginForm writes out the form elements in html to be able to post something back to an action inside some controller. Typically you will post to an action in the same controller (not always i know)
On the form in the html you usally specifiy which url to post the result to, and usally Html.BeginForm will take care of this when you specify actionname and controllername. But the problem here is that we have multiple languages (read: urls) pointing to the same action/controller in the RouteTable.
So my form is being submitted to the wrong language of the page, because Html.BeginForm picks up the wrong language url.
Have you setted different languages in your form action url?
Do you just use just like the following?
@
using
(Html.BeginForm()) {
<div >
<fieldset>
<div
class
=
"editor-label"
>
@Html.LabelFor(m => m.Account)
</div>
<div
class
=
"editor-field"
>
@Html.TextBoxFor(m => m.Account)
@Html.ValidationMessageFor(m => m.Account)
</div>
<div
class
=
"editor-label"
>
@Html.LabelFor(m => m.Password)
</div>
<div
class
=
"editor-field"
>
@Html.PasswordFor(m => m.Password)
@Html.ValidationMessageFor(m => m.Password)
</div>
<p>
<input type=
"submit"
value=
"submit"
/>
</p>
</fieldset>
</div>
}
I think you can use it like this:
@using (Html.BeginForm(new { Action = Model.ActionUrl }))
{
// Your form...
}
Yeah we could do it like that, but it is just as bad as creating the form element manually and specifying the url.
What would be nice is an EPiServer html helper extension that could take the current language into consideration, but i am guessing i am asking for too much :)
One day when I have oceans of time i will make it (read: never)
My colleague just found the solution when he was looking at linking to other language branches using Html.PageLink.
Adding langauge routevalue did the trick:
@using (Html.BeginForm("SubMitting", "Test", new {language= ContentLanguage.PreferredCulture.Name}))
{
}
So how does Html.BeginForm build the action url for the form element.
It uses the UrlHelper class. My guess is that it will somehow try to identify the url for a specific controller/action + routevalues using the routetable. But i am pretty sure that it does not take langauge under consideration when doing this (hint: it does not).
Well we did have problems with this, meaning submitting a simple form in a multi language episerver 7 mvc site.
We can solve it by manually creating the form element and getting the url for the page using http://joelabrahamsson.com/episerver-7-and-mvc-getting-the-url-for-a-page/ and adding the actionname to it.
But do anyone have alternative solution for this challenge?
I did try to make my own .BeginForm() extension for this, but of course some of the methods involved is marked as private and internal in the System.Web.Mvc assembly, so i gave up (not worth the effort imho)