Hi,
in Web part code in
"languageselectionwithflags1.ascx"<asp:Literal runat="server" ID="ltrDivOpen" EnableViewState="false" />
<asp:DropDownList OnSelectedIndexChanged="language_change" ID="DropDownList1"
runat="server" style="height: 22px" AutoPostBack="true"/>
<asp:Literal runat="server" ID="ltrDivClose" EnableViewState="false" />
in Web part code in
"languageselectionwithflags1.ascx.cs"using System;
using System.Data;
using System.IO;
using System.Web.Caching;
using CMS.PortalControls;
using CMS.GlobalHelper;
using CMS.CMSHelper;
using CMS.SiteProvider;
public partial class CMSWebParts_General_languageselectionwithflags : CMSAbstractWebPart
{
private string mLayoutSeparator = " ";
private string imgFlagIcon = "";
public string selectionClass = "";
#region "Public properties"
/// <summary>
/// Gets or sets the display layout
/// </summary>
public string DisplayLayout
{
get
{
return ValidationHelper.GetString(GetValue("DisplayLayout"), "");
}
set
{
SetValue("DisplayLayout", value);
mLayoutSeparator = value.ToLower() == "vertical" ? "<br />" : " ";
}
}
protected void language_change(object sender, EventArgs e)
{
UrlHelper.Redirect(DropDownList1.SelectedValue);
}
/// <summary>
/// Gets or sets the value that indicates whether the link for current culture should be hidden
/// </summary>
public bool HideCurrentCulture
{
get
{
return ValidationHelper.GetBoolean(GetValue("HideCurrentCulture"), false);
}
set
{
SetValue("HideCurrentCulture", value);
}
}
/// <summary>
/// Gets or sets the value than indicates whether culture names are displayed
/// </summary>
public bool ShowCultureNames
{
get
{
return ValidationHelper.GetBoolean(GetValue("ShowCultureNames"), true);
}
set
{
SetValue("ShowCultureNames", value);
}
}
/// <summary>
/// Gets or sets the separator between items
/// </summary>
public string Separator
{
get
{
return ValidationHelper.GetString(GetValue("Separator"), "");
}
set
{
SetValue("Separator", value);
}
}
#endregion
/// <summary>
/// Content loaded event handler
/// </summary>
public override void OnContentLoaded()
{
base.OnContentLoaded();
SetupControl();
}
/// <summary>
/// Reloads data for partial caching
/// </summary>
public override void ReloadData()
{
base.ReloadData();
SetupControl();
}
/// <summary>
/// Initializes the control properties
/// </summary>
protected void SetupControl()
{
if (StopProcessing)
{
// Do nothing
}
else
{
mLayoutSeparator = DisplayLayout.ToLower() == "vertical" ? "<br />" : " ";
DataSet ds = null;
// Try to get data from cache
using (CachedSection<DataSet> cs = new CachedSection<DataSet>(ref ds, this.CacheMinutes, true, this.CacheItemName, "languageselection", CMSContext.CurrentSiteName))
{
if (cs.LoadData)
{
// Get the data
ds = CultureInfoProvider.GetSiteCultures(CMSContext.CurrentSiteName);
// Save to the cache
if (cs.Cached)
{
cs.CacheDependency = CacheHelper.GetCacheDependency(new string[] { "cms.culturesite|all" });
cs.Data = ds;
}
}
}
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;
}
else
{
// Hide if less than two cultures
Visible = false;
}
if (string.IsNullOrEmpty(selectionClass))
{
ltrDivOpen.Text = "<div>";
}
else
{
ltrDivOpen.Text = "<div class=\"" + selectionClass + "\">";
}
ltrDivClose.Text = "</div>";
// Check if RTL hack must be applied
if (CultureHelper.IsPreferredCultureRTL())
{
ltrDivOpen.Text += "<span style=\"visibility:hidden;\">a</span>";
}
}
}
/// <summary>
/// Clears the cached items
/// </summary>
public override void ClearCache()
{
string useCacheItemName = DataHelper.GetNotEmpty(CacheItemName, CMSContext.BaseCacheKey + "|" + Context.Request.Url + "|" + ClientID);
CacheHelper.ClearCache(useCacheItemName);
}
}
The error I get on ListItem
"Error 3 The type or namespace name 'ListItem' could not be found (are you missing a using directive or an assembly reference?)"