Monday, 15 July 2019

Call JavaScript Function from Controller in ASP.Net MVC

///////////// Controller


ViewBag.JavaScriptFunction = string.Format("Search_Filter();");



/////////////  HTML


@if (ViewBag.JavaScriptFunction != null)
                {
                    <script type="text/javascript">
                        @Html.Raw(ViewBag.JavaScriptFunction)
                    </script>
                }
//////////////////// Js


function Search_Filter() {
alert(1);
}

No comments:

Post a Comment

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...