I have some code to booking tickets on movie. If somebody already booked ticket he may book more tickets, only if there is specific error message.
This var validationSummary receives only the tags (<span class="field-validation-valid" data-valmsg-for="Saving" data-valmsg-replace="true"></span>
). But in the web page @validationSummary prints correct message.
How can I and can I access the text of the error message to check it at all?
@{
@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
I solved this problem so:
@Html.ValidationSummary(true)
var validationSummary = Html.ValidationMessage("Saving");
bool bookAnotherVal = Html.ValidationSummary().ToString().Contains(BookingException.Msg_EmailDuplicatedBookAnother);
The ValidationSummary method displays a list of all validation messages on the page. (https://msdn.microsoft.com/en-us//library/system.web.mvc.html.validationextensions.validationsummary(v=vs.118).aspx)