Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 12c4de4

Browse files
Nitish KaushikNitish Kaushik
Nitish Kaushik
authored and
Nitish Kaushik
committed
validation summary in asp.net core
1 parent a8f1e79 commit 12c4de4

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

‎Webgentle.BookStore/Webgentle.BookStore/Controllers/BookController.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ public async Task<IActionResult> AddNewBook(BookModel bookModel)
5555
return RedirectToAction(nameof(AddNewBook), new { isSuccess = true, bookId = id });
5656
}
5757
}
58-
//ViewBag.IsSuccess = false;
59-
//ViewBag.BookId = 0;
6058

59+
ModelState.AddModelError("", "This is my custom error message");
60+
ModelState.AddModelError("", "This is my second custom error message");
6161

6262
return View();
6363
}

‎Webgentle.BookStore/Webgentle.BookStore/Views/Book/AddNewBook.cshtml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
}
1818

1919
<form method="post" asp-action="AddNewBook" asp-controller="Book">
20+
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
2021
<div class="form-group">
2122
<label asp-for="Title" class="control-label"></label>
2223
<input asp-for="Title" class="form-control" />

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /