I have a button triggering OnPost action
- <button asp-page-handler="PTWIssue" asp-route-idPTWNo="@Model.PTWNo" type="submit" class="btn btn-link text-info font-weight-bolder mt-2 mb-2" style="font-size:20px;" data-toggle="tooltip" data-placement="top" title="Issue the Permit to Work and send to Receiver">Issue Permit To Work</button>
On OnPost I have a check for string. I want to verify that there is no status "Awaiting" and then continue with OnPost. If the check fail, I want a simple message "Error on check" and the process to not continue. I have the following
- var checkIsoCert = await (from a in _context.IsoCerts.Where(s => s.PTWNo == idPTWNo)
- join b in _context.IsoDetails on a.IdIC equals b.IdIC into TempData1
- from c in TempData1
- select new { c.IsStatus }).ToListAsync();
-
- string myString = "Awaiting";
- var matchingvalues = checkIsoCert.Where(x => x.IsStatus.Equals(myString));
- if(matchingvalues == null)
- {
- var ptwStatus = _context.PTWContents.First(s => s.PTWNo == idPTWNo);
- ptwStatus.PTWStatus = "Issued";
- await _context.SaveChangesAsync();
- return RedirectToPage("PTWForm", "PTWNoId", new { ptwNoId = idPTWNo });
- }
- else
- {
-
- }
What I need is to display the message on error. How do I do that on Razor pages?