How do you see that it's wrong? Are you rendering the categories in the block template?
[Required]
[Editable(true)]
[Display(
Name = "Huvudnod för expertområde",
Description = "Välj den nod som utgör rooten för önskat expertområde.",
GroupName = SystemTabNames.Content,
Order = 180)]
public virtual CategoryList AreaOfExpertiseRoot { get; set; }
and in cshtml
@Html.DropDownList("areaofexpertise", Model.getExpertiseArea())
function getExpertisArea
public List<SelectListItem> getExpertiseArea()
{
if (AreaOfExpertiseRoot == null)
{
throw new ApplicationException("En huvudkategori för Expertområde är inte tilldelad. Det går inte att hämta expertområden.");
}
Category category = Category.Find(AreaOfExpertiseRoot.First());
var t = base.Property["DefaultAreaOfExpertis"];
var defaultExpertise = DefaultAreaOfExpertise != null ? DefaultAreaOfExpertise.First() : -1;
List<SelectListItem> selectListItems = new List<SelectListItem> { new SelectListItem { Value = "!", Text = AreaSelectorName, Selected = defaultExpertise == -1 ? true : false } };
List<Contact> contacts = getContactList();
if (category != null)
{
try
{
selectListItems.AddRange(from Category areaOfExpertise
in category.Categories
where contacts.Any(contact => contact.AreaOfExpertise.Contains(areaOfExpertise.ID))
select new SelectListItem { Value = areaOfExpertise.Name.Replace(" ", string.Empty), Text = areaOfExpertise.Name, Selected = ((defaultExpertise != -1) && (areaOfExpertise.ID == defaultExpertise)) ? true : false });
}
catch (Exception e)
{
//send error to logfile , redirect to errorpage!
}
}
return selectListItems;
}
The problem is that DefaultAreaOfExpertis never be null once we have value in it. When we set it to empty in contentarea it always remain last inserted value. Change value works though.
Are you doing programatical updates to the property. If so, this is a known bug that will be fixed in an update soon to be released.
thanks. But we are changing category with normal edit-ui. It works on the block/page but changes does'nt show in page that using block.
I'm having the same problem. The previous value is still available despite the fact that the field in Edit mode is empty.
I have created the following bug to investigate this:
What we discovered is that this can happen when you already assigned a non-CultureSpecific category to something, and then change the master language. Once you do this, EPiServer will still see and display the cateogries that are not in your master language, but you cannot edit or delete them from the CMS.
To get rid of those categories, you have to manually go into the database you configured and remove the items from [dbo].[tblContentCategory]
We created a shared block and used in a contentarea. Shared block has a category property and other properties. We update the category property with value it works in preview and in content area. When we upate the category property without any value ( remove all categories ) it works in preview but in contentarea it remains to previous value. Is it a bug? Is there any workaround for it?