Strange error with mandatory property value

Vote:
 

Page have the mandatory keyword-property. Keyword is a custom property which uses legacy editor to value selection. Keywords will be listed from another database.

If admin creates a new page there will be no problems at all.

If editor makes a new page EPi will first ask page name and type. No problems yet. Then EPi will ask mandatory keyword value. There is "click the button to edit"- button after Keyword-header. When user clicks the button this kind of error will appear instead of legacy editor and keyword lists:

--------------------------------------------------------------------------------
Access was denied to page . Missing required permissions to edit this page
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
wmmame
Exception Details: EPiServer.Core.AccessDeniedException: Access was denied to page . Missing required permissions to edit this page

Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:
[AccessDeniedException: Access was denied to page . Missing required permissions to edit this page]
EPiServer.UI.Edit.EditProperty.ValidateEditPermissions(IContent content) +194
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
System.Web.UI.Page.OnInit(EventArgs e) +105
EPiServer.UI.ContentBaseWebForm.OnInit(EventArgs e) +16
System.Web.UI.Control.InitRecursive(Control namingContainer) +133
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1970

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
--------------------------------------------------------------------------------

If I switch keyword property as not mandatory editor can add keywords without problems after page is created and added to pagetree. Customer still wants keywords to be madatory.

EPi version is 7.1. How can I fix this error?

#80276
Jan 20, 2014 11:11
Vote:
 

Can you post the custom property code? Especially the part where you save the property data.

#80330
Jan 21, 2014 8:57
Vote:
 

I' m thinking to a permission for editor problem. Seem that editor has not permission on the legacy page which used to display keywords data.

#80360
Jan 21, 2014 15:55
Vote:
 

Sorry my late answer. I think problem is not in legacy page because control is made as dynamically in CreateEditControls. EPi7 will put that control in legacy editor-box.

Keywords are saved in ApplyEditChanges method.

Here is some of the code:

 

public class PropertyKeywordsControl : PropertyDataControl
{
 System.Web.UI.WebControls.ListBox lBox;

public override void ApplyEditChanges() // saves property value
{
 string strKeywords = "";

 foreach (int i in lBox.GetSelectedIndices())
 {
  strKeywords += lBox.Items[i].Text + ", ";
 }

 // remove ", " from end of the string
 if (strKeywords.Length > 1)
  strKeywords = strKeywords.Remove(strKeywords.Length - 2, 2); 

 // Turns keyword list as comma separated GUID string.
 var keywords = CommaSeparatedStringHelper.ParseKeywordsToGUIDs(strKeywords);
 
 // save GUID list as Keywords custom property object
 var propertyValue = new Keywords();
 foreach (var keyword in keywords)
 {
  propertyValue.Add(keyword);
 }
 SetValue(propertyValue);
}

// Edit controls which will be presented in legacy editor - box
public override void CreateEditControls()
{
 lBox = new ListBox();
 lBox.Rows = 13;
 lBox.SelectionMode = ListSelectionMode.Multiple;

 // Get list of all keywords to listbox
 SubjectWS sWS = new SubjectWS();
 lBox.DataSource = sWS.ListOfKeywords();
 lBox.DataBind();

 // mark already selected keywords in listbox
 var keywords = PropertyData.Value as Keywords;
 string strKeywordlist = CommaSeparatedStringHelper.ConcatenateAsiasana(keywords) + ",";
 foreach (ListItem itmKeyword in lBox.Items)
  if (strKeywordlist.Contains(itmKeyword + ","))
   itmKeyword.Selected = true;
 
 // add listbox to editor view (in this case in legacy editor)
 this.Controls.Add(lBox);
 base.CreateEditControls();
}

. . .
}
  
public class Keywords : IEnumerable<string>, IReadOnly<Keywords>
{
// Keyword structure are pretty similar as this code example:
// http://joelabrahamsson.com/creating-a-custom-episerver-property-with-a-custom-class-as-value/
. . .
public Keywords()
{
 values = new List<string>();
}

public Keywords(string strKeywords)
{
 values = CommaSeparatedStringHelper.Parse(strKeywords);
}

public static List<string> ParseKeywordsToGUIDs(string values)
{
 // gets keyword GUIDs from cache and returns comma separated list of GUIDs
}
. . .
}

#80517
Jan 24, 2014 7:35
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.