Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Fernando Camillo 41 posts 82 karma points
    Oct 01, 2010 @ 14:35
    Fernando Camillo

    Backend user controls: How to set-up validation for then?


    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?



  • Aaron Powell 1708 posts 3045 karma points c-trib
    Oct 01, 2010 @ 15:02
    Aaron Powell

    I believe you can use the 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)

  • Fernando Camillo 41 posts 82 karma points
    Oct 01, 2010 @ 18:34
    Fernando Camillo

    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.


  • Giacomo Cosenza 16 posts 36 karma points
    May 03, 2011 @ 12:41
    Giacomo Cosenza

    Hi Fernando, you used Required Field Validator and works? How? 



  • Fernando Camillo 41 posts 82 karma points
    May 12, 2011 @ 15:33
    Fernando Camillo

    Hi Giacomo.

    Here goes the code:

    <asp:RequiredFieldValidator ID="myFieldRequiredValidator" runat="server" 
    Display="None" EnableClientScript="false"
    ErrorMessage="The field MyField is mandatory!">

    However, it doesn't obey the Umbraco checkbox "required". It's always required.


Please Sign in or register to post replies

Write your reply to: