1
I’m trying to make a website with support for two languages.
First test I did was to put this code inside a view
common, the index
of my control Home
.
Worked perfectly.
When I put the same code in a partial view
and call him in the view _layout
it doesn’t work. Can anyone tell me what I’m doing wrong?
Below is the code as it is in partial view
, what doesn’t work is form Submit.
@{
var culture = System.Threading.Thread.CurrentThread.CurrentUICulture.Name.ToLowerInvariant();
}
@helper selected(string c, string culture)
{
if (c == culture)
{
@:checked="checked"
}
}
@using (Html.BeginForm("SetCulture", "Home"))
{
<fieldset>
<legend></legend>
<div class="control-group">
<div class="controls">
<label for="en-us">
<input name="culture" id="en-us" value="en-us" type="radio" @selected("en-us", culture) /> English <img src="http://st.xptotube.com/img/180x135/l/blank.png" class="flag flag-us" alt="United States of America" />
</label>
</div>
</div>
<div class="control-group">
<div class="controls">
<label for="pt-br">
<input name="culture" id="pt-br" value="pt-br" type="radio" @selected("pt-br", culture) /> Portugues <img src="http://st.xptotube.com/img/180x135/l/blank.png" class="flag flag-br" alt="Brasil" />
</label>
</div>
</div>
</fieldset>
}
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
<script type="text/javascript">
(function ($) {
$("input[type = 'radio']").click(function () {
$(this).parents("form").submit(); // post form
});
})(jQuery);
</script>
}
I’m calling him that on _Layout:
@Html.Partial("_Language")
To Action
SetCulture
ofHomeController
comes to be called?– Leonel Sanches da Silva
It doesn’t get called no.
– Ricardo