I am generating some tabs dynamically. I end up with 4 tabs. The class of the tabs is beeing set in the foreach loop, and it is set to be the languageId, as you can see in the code below.
<div id="tabs">
<ul>
@for (int i = 0; i < Model.NoteViewModel.NoteTextViewModels.Count(); i++)
{
var languageId = @Model.NoteViewModel.NoteTextViewModels[i].LanguageId;
var imageName = string.Format("FlagSmall_{0}.gif", languageId);
<li>
<a href="#@languageId" class="@currentLanguage">
<img src="@Url.Content("~/Graphics/" + imageName)" />
</a>
</li>
}
</ul>
Now I introduce a new variable: var currentLanguage = new NotesController().LogonInfo.LanguageId; which holds the current language of the user logged in. What I want to do, is to set focus on the tab where href (or id or class) is the same as the currentLanguage. For this I guess I need js, but since I can't have js code with razor syntax, I'm stuck. So I want something like this:
@for (int i = 0; i < Model.NoteViewModel.NoteTextViewModels.Count(); i++)
{
var languageId = @Model.NoteViewModel.NoteTextViewModels[i].LanguageId;
var currentLanguage = new NotesController().LogonInfo.LanguageId;
var imageName = string.Format("FlagSmall_{0}.gif", languageId);
<li>
<a href="#@languageId">
<img src="@Url.Content("~/Graphics/" + imageName)" />
</a>
</li>
if (languageId == currentLanguage)
{
documentation.getElementById("currentLanguage").focus();
}
}
How can I achieve this?