Tuesday, June 30, 2009

Umbraco Member CanEdit == False?

How do you deal with this situation? In the members section of Umbraco there is a property called MemberCanEdit which then allows in theory a member to edit or not edit the property.

Each property renders a System.Web.UI.Control from the IDataEdtior interface. With System.Web.UI.Control there is no property which can disable the control as opposed to the System.Web.UI.WebControls.WebControl which you are normally use to which has the enabled property.

For controls which are infact webcontrols you can cast the control to a System.Web.UI.WebControl.WebControl control and you will then get the benefit of an enabled property. Not sure what do to do if this fails...Show a label instead?



if (mt.MemberCanEdit(pt))
{
_dataFields.Add(dt);
}
else
{
try
{
((System.Web.UI.WebControls.WebControl)dt.DataEditor.Editor).Enabled = false;
}
catch
{

}
}

No comments: