First Last

First Last

  • NA
  • 648
  • 72.3k

Viewbag content does not appear

Oct 6 2020 11:15 AM

I have an APS.Net web app Razor view where I attempt to display the Viewbag.errormessage.

The action method populates the viewbag but the view does not show the error message that is in the viewbag. It does not appear. Why?
 
 
 
 
 
Here is the view: 
  1. @Html.AntiForgeryToken()  
  2.   
  3. <div class="login-panel">  
  4.     @if (ViewBag.errormessage != null)  
  5.     {  
  6.         <p class="alert alert-danger" id="errorMessage">@ViewBag.errormessagep>  
  7.     }  
  8.   
  9.     <div class="form-group">  
  10.         <div class="col-md-12 col-xs-12">  
  11.             <h2>Delete Accounth2>  
  12.             <br />  
  13.             <h4 class="verify"><strong>I will need to verify your identity in order to delete your account.strong>h4>  
  14.             <br />  
  15.             <h4 class="verify"><strong>Please provide the following:strong>h4>  
  16.         div>  
  17.     div>  
  18.     <br />  
  19.     <div class="form-group">  
  20.         <div class="col-md-12 col-xs-12">  
  21.             <br />  
  22.             <label class="manadatory" for="UserName">User Namelabel>  
  23.             <input id="UserName" type="text" value="" name="UserName">  
  24.         div>  
  25.     div>  
  26.   
  27.     <div class="form-group">  
  28.         <div class="col-md-12 col-xs-12">  
  29.             <br />  
  30.             <label class="manadatory" for="Password">Passwordlabel>  
  31.             <input id="Password" type="text" value="" name="Password">  
  32.         div>  
  33.     div>  
  34.   
  35.     <div class="form-group">  
  36.         <div class="col-md-offset-0 col-md-10">  
  37.             <br />  
  38.             <input class="btn btn-primary deleteUserAccount" value="Delete Account">  
  39.             @Html.ActionLink("Cancel", "Index", "User", null, new { @class = "btn btn-info" })  
  40.         div>  
  41.     div>  
  42. div>  
  43.   
  44. <div class="modal fade" id="myModal4" role="dialog" display="none">  
  45.     <div class="modal-dialog">  
  46.         <div class="modal-content">  
  47.             <div class="modal-body" style="padding:10px;">  
  48.                 <h4 class="text-center">Are you sure you want to permanently delete your account and all it contains?  Continue ?h4>  
  49.                 <div class="text-center">  
  50.                     <a class="btn btn-info btn-yes4">Yesa>  
  51.                     <a class="btn btn-default btn-no4">Noa>  
  52.                 div>  
  53.             div>  
  54.         div>  
  55.     div>  
  56. div>  
  57.   
  58. @Scripts.Render("~/bundles/jqueryval")  
  59. @Scripts.Render("~/bundles/jquery")  
  60. @Scripts.Render("~/bundles/bootstrap")  
  61. @Styles.Render("~/Content/css")  
  62.   
  63.   
  64. <script type="text/javascript">  
  65. $(document).ready(function () {  
  66.    // code...  
  67. script>  
 

Answers (5)