2016年5月3日 星期二

C# MVC 3 以上 RenderSection 用法說明


RenderSection 用法說明:當頁面載入時會有順序問題,如果不加入section scripts 就在layout.html寫script將會發生錯誤,因為jquery pluging 尚未載入,所以加入section scripts後就會在plugin載入後才呼叫script


=====================================


    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/bootstrap")
    @RenderSection("scripts", required: false)
</body>
</html>
@section scripts{
   
    <script>
        alert('123');
    </script>
   
    }

沒有留言:

張貼留言