Here I have ViewBag in a controller which contains text i.e ViewBag.Msg = "No Sprint"
.
And I am trying to use ViewBag.Msg in Jquery to display modal.
Now, the problem is that the script is script never gets executed.
Below is my jQuery.
<script>
$(document).ready(function () {
debugger;
if (@ViewBag.Msg != null)
{
$("#myModal").modal();
}
});
</script>
Any help will be highly appreciated. Thank You.
Please use the below code.
<script>
$(document).ready(function () {
debugger;
var msg='@ViewBag.Msg';
if (msg !== '')
{
$("#myModal").modal();
}
});
</script>