Hi,
You can create simple language dropdown list following way:
- to .ascx file add this control
<asp:DropDownList OnSelectedIndexChanged="language_change" ID="DropDownList1"
runat="server" style="height: 22px" AutoPostBack="true"/>
- to .ascx.cs add this method
protected void language_change(object sender, EventArgs e)
{
UrlHelper.Redirect(DropDownList1.SelectedValue);
}
- in
protected void SetupControl() method replace only "if" part of condition
if (!DataHelper.DataSourceIsEmpty(ds) && (ds.Tables[0].Rows.Count > 1))with following code (please leave else part as it is):
if (!DataHelper.DataSourceIsEmpty(ds) && (ds.Tables[0].Rows.Count > 1))
{
// Build current URL
string url = UrlHelper.CurrentURL;
url = UrlHelper.RemoveParameterFromUrl(url, UrlHelper.LanguageParameterName);
url = UrlHelper.RemoveParameterFromUrl(url, UrlHelper.AliasPathParameterName);
string ltlHyperlinks = "";
int count = 0;
int rows = ds.Tables[0].Rows.Count;
foreach (DataRow dr in ds.Tables[0].Rows)
{
string cultureCode = dr["CultureCode"].ToString();
string cultureShortName = dr["CultureShortName"].ToString();
if (!((HideCurrentCulture) && (String.Compare(CMSContext.CurrentDocument.DocumentCulture, cultureCode, true) == 0)))
{
// Add flag icon before the link text
ltlHyperlinks = HTMLHelper.HTMLEncode(UrlHelper.AddParameterToUrl(url, UrlHelper.LanguageParameterName, cultureCode));
// Add language to dropdown list
DropDownList1.Items.Add(new ListItem(HTMLHelper.HTMLEncode(cultureShortName), ltlHyperlinks));
// Set surrounding div css class
selectionClass = "languageSelectionWithCultures";
}
count++;
}
// Set item in DropDownList1 to Selected
DropDownList1.Items.FindByValue(UrlHelper.AddParameterToUrl(url, UrlHelper.LanguageParameterName, CookieHelper.GetValue("CMSPreferredCulture"))).Selected = true;
}
Best regards,
Ivana Tomanickova