View the Validation summery in the required place

349 views Asked by At

I have a partial view in a main view in mvc3. The partial view has it's own ModelState.AddModelError in its action method and the main view has another ModelState.AddModelError in its action method. When the code runs and the main view error wants to be displayed, as the partial view also has the validationsummery tag, the validation summery shows up in both places.

How an I fix this issu?? Thanks.

1

There are 1 answers

0
Ancient On

You can do this by jquery

$(function(){
    var error = "";
    $("classnameOfvalidationsummarydiv").each(function(){

        error = error + $(this).html();

    });

    $("idOfDivWhereuwanttoshow").append(error);



  });

Hope this will work