Hi @OneWorld,
Based on the code you provided, you should want to implement the MessageBox in MVC.
You can try the code below.
<script src="~/Scripts/jquery-3.7.1.min.js"></script>
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog err-pop" style="">
<div class="modal-content">
<div class="modal-header">
<button id="DivClose" type="button" class="close" data-bs-dismiss="modal" aria-label="Close">×</button>
</div>
<div class="modal-body" style="text-align:center;">
<p style="color: red;">@TempData["ProcessMessage"]</p>
</div>
</div>
</div>
</div>
@if (TempData["message"] != null)
{
var modal = TempData["message"].ToString();
<script type='text/javascript'>
$(document).ready(function(){
$('#@modal').modal('show');
});
</script>
}
public ActionResult Test4()
{
TempData["ProcessMessage"] = "Please, update your account";
TempData["message"] = "myModal";
return View();
}
System.InvalidOperationException: 'The RouteData must contain an item named 'action' with a non-empty string value.
you need to add route data. Exception tell you everything.
var routeData = new RouteData() ;
routeData.Values.Add("Controller", "Home");
routeData.Values.Add("Action", "Index");
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.