如何在模板的内容页中添加javascript代码?

  今天想在内容页的input标签上添加一个JQueryUI控件,用来做一个点击文本框弹出日期选择器的效果,但是无论我将JS代码放在模板MasterPage中还是放在内容页的ContentPlaceHolder中,JS代码都没有正常运行,看不到JQuery效果,经过反复研究得出结论,JS代码必须放在内容页的Head ContentPlaceHolder中,例如代码如下:

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <link href="css/smoothness/jquery-ui-1.8.14.custom.css" rel="stylesheet" type="text/css" />
    <script src="js/jquery-1.6.1.js" type="text/javascript"></script>
    <script src="js/jquery-ui-1.8.14.custom.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function() {
            $("#<%=txtBrithday.ClientID %>").datepicker({
                changeMonth: true,
       changeYear: true
            });
            $("#<%=txtRegDate.ClientID %>").datepicker({
                showOn: "button",
                buttonImage: "images/calendar.gif",
                buttonImageOnly: true
            });
        });
    </script>
</asp:Content>

原文地址:https://www.cnblogs.com/mcgrady/p/2169145.html