简体   繁体   English

在所需的位置查看验证摘要

[英]View the Validation summery in the required place

I have a partial view in a main view in mvc3. 我在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. 局部视图在其动作方法中具有自己的ModelState.AddModelError,主视图在其动作方法中具有另一个ModelState.AddModelError。 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. 当代码运行并且想要显示主视图错误时,由于部分视图也具有validationsummery标签,因此两个地方都将显示验证文本。

How an I fix this issu?? 我该如何解决此问题? Thanks. 谢谢。

You can do this by jquery 你可以通过jQuery来做到这一点

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

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

    });

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



  });

Hope this will work 希望这会起作用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM