Use TempData or ViewBag to render HTML

This is a very basic example;

Declare this in a controller.

var fontAwesomeIcon = "<span class=\"fa fa-redo\" style=\"font-size:30px; color: red; margin-bottom: 20px; \">&nbsp;Try again</span>";

TempData["message"] = $"{fontAwesomeIcon} <h5>Something went wrong. Please try again. If problem persist, reach out to your point of contact for additional information</h5>";

And you can use it in your view;

<div class="card-body">
  <div id="divMessage">
     @Html.Raw(@TempData["message"]);
  </div>
</div>            

FavoriteLoadingAdd to favorites
Spread the love

Author: Shahzad Khan

Software developer / Architect