Custom DataType Country List - alternative to uComponents Country Picker
Hi,
I was using uComponents Country Picker but a heap of countries were missing from the list.
So here is the code for a custom datatype of countries.
In the /usercontrols folder add this code to CountryDropDown.ascx.cs
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
namespace MyProject
{
public partial class CountryDropDown : System.Web.UI.UserControl, umbraco.editorControls.userControlGrapper.IUsercontrolDataEditor
{
public string umbracoValue;
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack)
{
umbracoValue = ddlCountry.SelectedValue;
}
var addedCountries = new List<string>();
foreach (System.Globalization.CultureInfo cultureInfo in System.Globalization.CultureInfo.GetCultures(System.Globalization.CultureTypes.SpecificCultures))
{
System.Globalization.RegionInfo regionInfo = new System.Globalization.RegionInfo(cultureInfo.LCID);
if (!addedCountries.Contains(regionInfo.EnglishName))
{
addedCountries.Add(regionInfo.EnglishName);
}
}
foreach (var c in addedCountries.OrderBy(q => q).ToList())
{
ddlCountry.Items.Add(new ListItem(c, c));
}
ddlCountry.Items.Insert(0, new ListItem("", " - Country - "));
if (!String.IsNullOrEmpty(umbracoValue)){
ddlCountry.SelectedValue = umbracoValue;
}
}
public object value
{
get
{
return umbracoValue;
}
set
{
umbracoValue = value.ToString();
}
}
}
}
Then in Developer section of the back end Right-click on DataTypes and select "Create".
Give the DataType a name like "Country DropDown", then in the Property Editor List select "Umbraco Usercontrol Wrapper".
Then Save and select your CountryDropDown.ascx user control in the User Control list.
Select Database Datatype and Save.
All done... now you can add this to your properties.
Custom DataType Country List - alternative to uComponents Country Picker
Hi,
I was using uComponents Country Picker but a heap of countries were missing from the list.
So here is the code for a custom datatype of countries.
In the /usercontrols folder add this code to CountryDropDown.ascx.cs
Then in the CountryDropDown.ascx
Remember to compile...
Then in Developer section of the back end Right-click on DataTypes and select "Create".
Give the DataType a name like "Country DropDown", then in the Property Editor List select "Umbraco Usercontrol Wrapper". Then Save and select your CountryDropDown.ascx user control in the User Control list. Select Database Datatype and Save.
All done... now you can add this to your properties.
Please note...
To get this control working in the Member Properties I had to change the value saving code from
to
is working on a reply...