开发者

javascript placed inside an usercontrol loads but does not execute

inside a user control I have placed:

&l开发者_运维知识库t;script type="text/javascript">
        $(function () {
            alert("foooo");

        };        
</script>

This javascript loads into the browser fine, but does not executes. What is the proper way to add javascript code to a user control in ASP.NET MVC.


I have no experience with asp.net but the above is invalid JavaScript (no closing right parenthesis). Have you tried some very simple code like this:

<script type="text/javascript">
    alert("foo");
</script>


You're missing a close paren at the end of your function. It should be like this:

});


Be sure that you have JQuery library referenced. Check it like with below code :

<script type="text/javascript">


    if(JQuery == "undefined") { 

          alert("you didn't referenced the JQuery properly!")
    }

        $(function () {
            alert("foooo");

        });        
</script>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜