Hi @Joyce,
Please use @Html.Raw(ViewData["Message"])
instead of @ViewData["Message"]
. Here is my sample code and test result.
@section scripts {
<script type="text/javascript">
window.onload = function () {
//alert("@ViewData["Message"]");
alert("@Html.Raw(ViewData["Message"])");
};
</script>
}
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.
Best regards,
Jason