Backend user controls: How to set-up validation for then?
Hi.
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'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)
Backend user controls: How to set-up validation for then?
Hi.
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?
Thanks!
Fernando
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)
Hi Slace.
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.
Fernando
Hi Fernando, you used Required Field Validator and works? How?
Thanks
G.
Hi Giacomo.
Here goes the code:
However, it doesn't obey the Umbraco checkbox "required". It's always required.
Fernando
is working on a reply...