User-1355965324 posted
When I call the function ShowResultModalPopup from inside the if condition , the error message ' The name ShowResultModalPopup doesnot exist in the current context error is coming. If I am calling without if condition there is
no error will be coming. How can I call the function only if ViewBag.Result is not null or not empty. The function I have declared in site.js
<script type="text/javascript">
$(document).ready(function () {
@if(ViewBag.Result !=null && ViewBag.Result !="")
{
ShowResultModalPopup('@ViewBag.Result');
}
@if (@ViewBag.Error != null && @ViewBag.Error != "")
{
ShowResultModalPopup('@ViewBag.Result');
}
})
in Site.Js
function ShowResultModalPopup(message) {
if (message !== '') {
$('#divMessage').html(message);
$('#ResultModal').modal('show');
}
}
function ShowErrorModalPopup(message) {
if (message !== '') {
$('#divErrorMessage').html(message);
$('#ErrorModal').modal('show');
}
}