Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I've made a very simple user control for tests in the backend. It's a combobox with 3 values:- Choose (empty string)- Male ("M" string)- Female ("F" string)
The control is working, the data is being saved in umbraco database. However, if I check the "required" option for this type in the document type properties, umbraco ignores this and allows contents to be saved with this field empty.
What can I do to handle validation for my backend user control?
I believe you can use the ValidationPropertyAttribute (http://msdn.microsoft.com/en-us/library/system.web.ui.validationpropertyattribute ) but I don't think it's 100% reliable.
I'd recommend that you do validation by putting your own validation controls into the User control. I don't know how (or if it's possible) to work out from a data type whether it is set as a 'required' property on a document type (without a lot of nasty hacks :P)
Thanks! You're right. I used a "Required Field Validator" inside the user control, and now it works like a charm!
Thank you again for the help.
Hi Fernando, you used Required Field Validator and works? How?
Here goes the code:
<asp:RequiredFieldValidator ID="myFieldRequiredValidator" runat="server" Display="None" EnableClientScript="false" ControlToValidate="myDropDownList" ErrorMessage="The field MyField is mandatory!"></asp:RequiredFieldValidator>
However, it doesn't obey the Umbraco checkbox "required". It's always required.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted