Sun*_*mal 2 asp.net jquery jquery-ui
我正在使用ASP.NET开发一个网站,我将在我的网站中使用jQuery datepicker.我使用了以下代码,但它不起作用.有谁知道为什么?
<link href="css/calendar/jquery-ui-1.8.7.custom.css" rel="stylesheet" type="text/css" />
<script src="jquery/calendar/jquery-1.4.4.min.js" type="text/javascript"></script>
<script src="jquery/calendar/jquery-ui-1.8.7.custom.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
$("#txtEventDate").datepicker();
});
</script>
Run Code Online (Sandbox Code Playgroud)
这是我的文本框HTML代码:
<asp:TextBox ID="txtEventDate" runat="server" Width="125px"></asp:TextBox>
Run Code Online (Sandbox Code Playgroud)
dig*_*uru 12
也许文本框的ID不是"txtEventDate" - 它可能是"ctrl00-ucDatePicker-txtEventDate"或者asp.net倾向于动态生成ID的东西.
我的建议是通过你分配给盒子的课程选择它,或者
<asp:textbox id="txtEventDate" runat="server" cssclass="date-picker" />
Run Code Online (Sandbox Code Playgroud)
然后应用使用类选择器而不是ID选择器
$(".date-picker").datepicker()
Run Code Online (Sandbox Code Playgroud)
或者如果javascript位于页面中,您可以考虑...
$("#<%= txtEventDate.ClientID %>").datepicker()
Run Code Online (Sandbox Code Playgroud)
或者您可以尝试部分ID选择器
$("input[id*=txtEventDate]").datepicker()
Run Code Online (Sandbox Code Playgroud)
有三种解决方案供您使用!
归档时间: |
|
查看次数: |
10259 次 |
最近记录: |