ASP.NET MVC Javascript ActionResult

前端 未结 3 1759
我寻月下人不归
我寻月下人不归 2020-12-09 18:10

Anyone have any examples of javascript actionresults? I am having a hard time getting the script to execute once it has been returned. Thanks

3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-09 18:30

    The only way I have found to return a JavascriptResult and execute it on the client is with JQuery:

    
    
    
    

    In the controller:

    public JavaScriptResult ShowAlert() {
            var script = "alert('Hello');";
            return new JavaScriptResult() { Script = script };
    }
    

提交回复
热议问题