I am trying to call a js function inside my view :
@model DomainClass.Group
@{
ViewBag.Title = "Edit";
Layout = "~/Views/Shared/_Layout.cshtml";
<script language="javascript" type="text/javascript">
document.read = function myFunction() {
if (ViewBag.State == "error") {
if (confirm("معیار مورد نظر دارای زیر مجموعه های مرتبط است. آیا تمایل به ویرایش دارید ؟")) { } else {
history.back();
}
}
}
</script>
}
}
@using (Html.BeginForm())
{
//my code
}
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
As you can see the my function name is myfunction and it depends on viewbag value ,but never it is't called by browser!!!
Should i add extra code to my view ?
Any ideas will be appreciated .
Best regards
$(document).ready(function() {}which calls your function