ValidationSummary is not displaying

Hi Experts,
I have done this multiple times and it usually works with no problems but for the life of me I can figure out what I'm doing wrong this time.
I'm calling my action to enter data into the DB but first I run validation on it and I know that it is failing validation as I have first name and last name as required.
 public ActionResult Create([Bind(Include ="F_Name,L_Name,HireDate,LAN_ID,Office_ID")] Employee e)
        {
            try
                {
                    HRRepository RR = new HRRepository();
                 if(!ModelState.IsValid)                 
                    {
                        var allerrors = ModelState.Values.SelectMany(v => v.Errors).ToArray();
                        foreach (ModelError error in allerrors)
                        {
                            ModelState.AddModelError("", error.ErrorMessage.ToString());
                        }
                        return View("Index");      
                    }
                 else
                   {
                       RR.Enter_NewHire(e);
                       ViewBag.ShowPartial = true;
                       return View("Index");  
                  }
                }
                catch(Exception ex)
                {
                    return View("Error", new HandleErrorInfo(ex, "App", "Create"));
                }

Open in new window


I can watch the 2 messages being attached as it runs in debug mode but when the page is displayed the is no validation summary

Here is the top of the view
@using (Html.BeginForm("Create", "NewHires", FormMethod.Post))
{
    @Html.AntiForgeryToken()   
    @Html.ValidationSummary(false, "Please Correct Errors")
     <div id="divmain" style="margin-left:10em;">
    <fieldset>

Open in new window


I use jquery while passing the data to the action but I have done this multiple times before. The problem is probably staring me in the face but I just can't see it.
Any help would be greatly appreciated.
Thanks in advance
Niall292Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Najam UddinCommented:
You are not specifying the control for which you are putting error message

ModelState.AddModelError("controlName", Message);

Open in new window

0
Niall292Author Commented:
When putting the error message in the validation-summary you do not put in a name.
You used to have to put in string.Empty() but in MVC 4 (or possibly 3) they changed it so you just had to put in ""
0
Niall292Author Commented:
I got it to work by putting in an ID for the form
@using (Html.BeginForm("Create", "NewHires", FormMethod.Post, new{id = "frmCreateNewHire"}))
{

Open in new window


and then calling it after button click in jquery
$('#SaveEmp').on('click', function () {
....
.......
if($('#frmCreateNewHire').valid())
{
SaveNewHires( fname,lname, hiredate, lanname, officeid);
}
});

Open in new window


and the summary showed up
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Niall292Author Commented:
This solution works good to show the user that the data did not validate on client side which would do my job because it is an intranet  site.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.