I'm sure I'm doing something stupid here! I have created a usercontrol wrapper data type which works perfectly when the content is valid but if the content is not valid the property is saved blank (if you go to another node and back again), even if it was perviously saved valid.
Here is my code:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (!string.IsNullOrEmpty(_umbracoValue))
editorSource.Text = _umbracoValue;
}
else if (IsValid)
{
_umbracoValue = editorSource.Text;
}
}
#region IUsercontrolDataEditor Members
private string _umbracoValue;
object umbraco.editorControls.userControlGrapper.IUsercontrolDataEditor.value
{
get
{
return _umbracoValue;
}
set
{
_umbracoValue = value.ToString();
}
}
Can someone please point out what I am doing wrong!
Thanks for replying, my problem is I have some logic checks to perform on the content and if they fail I would like to prevent the content being published but allow save, maybe this is not possible with the wrapper?
Ok, thanks, but then I need to know the property alias being used for the data type (which I might not)? I'm thinking I need to use a AbstractDataEditor instead of Wrapper as I can then implement my validation logic in the data type, right?
Usercontrol Wrapper Data Type blank on reload
I'm sure I'm doing something stupid here! I have created a usercontrol wrapper data type which works perfectly when the content is valid but if the content is not valid the property is saved blank (if you go to another node and back again), even if it was perviously saved valid.
Here is my code:
Can someone please point out what I am doing wrong!
Thanks!,
Jeavon
Comment author was deleted
Hey Jeavon,
I would drop the else if in the page_load and move that to the get of the value property
get
{
return editorSource.text;
}
Hi Tim,
Thanks for replying, my problem is I have some logic checks to perform on the content and if they fail I would like to prevent the content being published but allow save, maybe this is not possible with the wrapper?
Thanks,
Jeavon
Comment author was deleted
Well you'll need to move that logic to an event handler on the before publish event and cancel publication if it doesn't meet your check
Ok, thanks, but then I need to know the property alias being used for the data type (which I might not)? I'm thinking I need to use a AbstractDataEditor instead of Wrapper as I can then implement my validation logic in the data type, right?
is working on a reply...