问题
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