Validation Message

Last post 07-05-2009 9:08 PM by shapper. 4 replies.

Sort Posts:

  • Validation Message

    04-26-2009, 10:41 AM
    • Contributor
      3,567 point Contributor
    • shapper
    • Member since 11-28-2004, 4:15 PM
    • Posts 2,935

    Hello,

    On a create / edit form I have the following:

     <%=Html.ValidationSummary("Correct the errors")%>
     <ol>
        <li>
          <label for="Title" class="Required">Título</label>
          <%=Html.TextBox("Title", Model.Article.Title != null ? Model.Article.Title : String.Empty, new { })%>
          <%=Html.ValidationMessage("Title")%>

    The summary shows the error message " 'Title' should not be empty." instead of "Correct the errors".

    And the Html.ValidationMessage does not show the message "'Title' should not be empty.".

    What am I doing wrong?

    Thanks,

    Miguel

  • Re: Validation Message

    04-26-2009, 11:01 AM
    Answer
    • Contributor
      5,969 point Contributor
    • gerrylowry
    • Member since 07-02-2008, 9:46 PM
    • alliston ontario canada
    • Posts 2,165

    Miguel, I think you need to read these tutorials at http://www.asp.net/learn/mvc/:

    #18 | Performing Simple Validation View in VB or C# 
    #19 | Validating with the IDataErrorInfo Interface View in VB or C#
    #20 | Validating with a Service Layer View in VB or C#

    You might find the strategy discussed in tutorial # 19
    will resolve your issue.

    Basically, you are adding on to a partial class.

    Regards,
    Gerry (Lowry)

    Gerry Lowry, Principal
    Ability Business Computer Services ~~ Because it's your Business, our Experience Counts!
    68 John W. Taylor Avenue
    Alliston · Ontario · Canada · L9R 0E1 · gerry.lowry@abilitybusinesscomputerservices.com

    Websites:
    http://abilitybusinesscomputerservices.com
    http://gerrylowryprogrammer.com ~~ résumé & testimonials
    http://veganoccasions.com ~~ recipes by Susan
  • Re: Validation Message

    04-26-2009, 1:55 PM
    • Contributor
      3,567 point Contributor
    • shapper
    • Member since 11-28-2004, 4:15 PM
    • Posts 2,935

    Hi,

    I had used Simple Validation and IDataErrorInfo ... As well as a custom Validation Service Layer.

    But that's not the problem. At the moment I am using Fluent Validation:

    http://www.codeplex.com/FluentValidation

    On my custom Model Binder I have the following:

          ValidatorFactory factory = new ValidatorFactory();
          IValidator<ArticleModel> validator = factory.GetValidator();
          ValidationResult result = validator.Validate(model);
          result.AddToModelState(bindingContext.ModelState, "");

    On the summary I get the errors but not on the individual validators.

    Does anyone knows what am I missing?

    Thanks,

    Miguel 

     

  • Re: Validation Message

    07-05-2009, 4:05 AM
    Answer
    • Contributor
      5,969 point Contributor
    • gerrylowry
    • Member since 07-02-2008, 9:46 PM
    • alliston ontario canada
    • Posts 2,165

    Miguel, did you resolve this issue?

    If not, you'll find some more interesting links here:  http://forums.asp.net/p/1443295/3275192.aspx#3275192.

    If you did resolve this, please share your solution with the rest of the community members.

    Thank you.

     

    Regards,
    Gerry (Lowry)

    Gerry Lowry, Principal
    Ability Business Computer Services ~~ Because it's your Business, our Experience Counts!
    68 John W. Taylor Avenue
    Alliston · Ontario · Canada · L9R 0E1 · gerry.lowry@abilitybusinesscomputerservices.com

    Websites:
    http://abilitybusinesscomputerservices.com
    http://gerrylowryprogrammer.com ~~ résumé & testimonials
    http://veganoccasions.com ~~ recipes by Susan
  • Re: Validation Message

    07-05-2009, 9:08 PM
    Answer
    • Contributor
      3,567 point Contributor
    • shapper
    • Member since 11-28-2004, 4:15 PM
    • Posts 2,935

    Hi Gerry,

    I have been using Fluent Validation and I am really happy with it:

    http://fluentvalidation.codeplex.com/

    The project owner is also really fast in answering questions in when possible includes new funcionalities to it.

    It is really good for MVC. I highly recommend it.

    Thanks,

    Miguel

Page 1 of 1 (5 items)