locked
SL3 WCF RIA DataForm validation - a field name is added to ErrorMessage RRS feed

  • Question

  • Hi.

    I have set validation attributes in my domain service like

    [Required(AllowEmptyStrings = false, ErrorMessage = "'Phone' field can not be empty")] - UI for 'Phone' field is textbox
    [Required(AllowEmptyStrings = false, ErrorMessage = "'Income Type' field can not be empty")] - UI for 'Income Type' is combobox, data is based on navigation entity 'vwIncomeType'.

    When validating, dataform displays exact ErrorMessage for the combobox, but for the text box it adds one more 'Phone' word, in bold:
    Phone 'Phone' field can not be empty.

    How can I get rid of this added word? Or - make combobox'es ErrorMessage to appear alike - if I don't set ErrorMessage for combobox, I get 'vwIncomeType can not be empty, and renaming data model's entities/properties is not an option.

    TIA,
    Alexey

    Friday, August 6, 2010 5:23 PM

Answers

  • Hi,

       You can get rid of the added text by telling it there is nothing to add

            [Required(AllowEmptyStrings= false,ErrorMessage="Test is a test")]
            [Display(Name="")] //this line is what you are looking for
            public string Name 

    Best Regards

    Tuesday, August 10, 2010 2:30 AM