View the Validation summery in the required place

淺唱寂寞╮ 提交于 2020-01-16 00:27:06

问题


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:


You can do this by jquery

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

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

    });

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



  });

Hope this will work



来源:https://stackoverflow.com/questions/5102597/view-the-validation-summery-in-the-required-place

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!