title: MVC3 How to add validation errors dynamically
body: <p>I am trying to show the error message on view. Can you please suggest me the right approach to do this. I was thinking to add the data annotation dynamically but can't find any solution. </p>
  
  <p>Thanks </p>
  
  <pre><code>[HttpPost]
  public ActionResult AddBook(BooksModel booksModel)
  {           
      try
      {
          booksModel.Account = _bookRepository.BookDetails(booksModel.Title,booksModel.RefCode, booksModel.DontHaveRefCode);
      }
      catch (FaultException faultException)
      {
          switch (faultException.Code.Name)
          {
              case "exc1":
              // Show Error Message Here
              return View("AddBook", booksModel);
              default:
              break;
          }
      }
      return View("ConfirmBook", booksModel);
  }
  </code></pre>