I have a view (eg. Index.cshtml) and in page model (eg. Index.cshtml.cs). There's one javascript function in view that I want to call from OnPost() method in page model. So I tried using ScriptManager but it says that "ScriptManager does not exists in current context". Clicking "Show potential fixes" doesn't show any solution to solve this error.
How to solve this or is there any other alternative way to call javascript function from page model?
My Javascript in View:
<script type="text/javascript">
function openModal() {
$('#myModal').modal('show');
}
</script>
My code to call the javascript function using ScriptManager in Page Model:
public ActionResult OnPost(){
........//Some codes
........//Some codes
ScriptManager.RegisterStartupScript(this,this.GetType(),"Pop", "openModal();", true);
}
Appreciate any help and suggestions. Thanks in advance!