0

我有一些预订电影票的代码。如果有人已经订了票,他可以订更多票,只有当有特定的错误信息时

此 var validationSummary 仅接收标签 ( <span class="field-validation-valid" data-valmsg-for="Saving" data-valmsg-replace="true"></span>)。但是在网页中@validationSummary 打印出正确的信息。 我怎样才能并且可以访问错误消息的文本以完全检查它?

@{
    @Html.ValidationSummary(true)
    var validationSummary = Html.ValidationMessage("Saving");
    bool buyAnotherVal = validationSummary.ToString().Contains("By continuing this form, you will booking another some tickets");
 }
 @using ( Html.BeginUmbracoForm<MovieBookingSurfaceController>( "SubmitBuyerDetails", new { buyAnother = buyAnotherVal }) )
 {
    @validationSummary
4

1 回答 1

0

我这样解决了这个问题:

@Html.ValidationSummary(true)
var validationSummary = Html.ValidationMessage("Saving");
bool bookAnotherVal = Html.ValidationSummary().ToString().Contains(BookingException.Msg_EmailDuplicatedBookAnother);

ValidationSummary 方法显示页面上所有验证消息的列表。(https://msdn.microsoft.com/en-us//library/system.web.mvc.html.validationextensions.validationssummary(v=vs.118).aspx

于 2017-11-16T09:58:40.690 回答