[英]Why doesn't my jquery date-picker not work in my asp.net code?
I am trying to use jquery datepicker in my asp.net page. 我试图在我的asp.net页面中使用jquery datepicker。 Somehow it isnt working and i saw alot of answers and also the
jquery-ui's api
, and i see no difference in what different i am doing .. 不知何故它不起作用,我看到了很多答案,还有
jquery-ui's api
,我发现我在做什么方面没有区别..
Here is my aspx
code : 这是我的
aspx
代码:
<div class="form-group"
<asp:Label ID="Label2" runat="server" CssClass="col-sm-2 col-sm-2 control-label" Text="Event Date :" Font-Bold="true" ForeColor="SlateBlue" Font-Size="Larger" />
<div class="col-sm-10">
<asp:TextBox ID="txtEventDate" runat="server" CssClass="form-control"></asp:TextBox>
</div>
</div>
My script is : 我的脚本是:
<script>
$(document).ready(function () {
$('#txtEventDate').datepicker({
numberOfMonths: 2,
showButtonPanel: true
});
});
</script>
Now , upon DOM inspection i found that the ID
is not rendered as txtEventDate
but as ContentPlaceHolder1_txtEventDate
( Note : I am using a master page here. ) 现在,在进行DOM检查后,我发现该
ID
不是呈现为txtEventDate
而是呈现为ContentPlaceHolder1_txtEventDate
( 注意:我在此处使用母版页。)
I do not know why exactly the script is not working . 我不知道为什么该脚本无法正常工作。 is that because of the rendered different
ID
?? 是因为呈现了不同的
ID
?
My jquery implementation : 我的jQuery实现:
following are in masterpage : 以下是主页:
<script src="assets/js/jquery.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/jquery-ui-1.9.2.custom.min.js"></script>
<script src="assets/js/jquery.ui.touch-punch.min.js"></script>
<script class="include" type="text/javascript" src="assets/js/jquery.dcjqaccordion.2.7.js"></script>
<script src="assets/js/jquery.scrollTo.min.js"></script>
<script src="assets/js/jquery.nicescroll.js" type="text/javascript"></script>
<!--common script for all pages-->
<script src="assets/js/common-scripts.js"></script>
And the one's i have included(just to be safe0 on the page where i am using datepicker()
: 我已经包括了(只是为了在我使用
datepicker()
的页面上使用safe0:
<script src="assets/js/jquery.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/jquery-ui-1.9.2.custom.min.js"></script>
you should be able to change this: 您应该可以更改此设置:
$('#txtEventDate').datepicker({
to: 至:
$('#<%=txtEventDate.ClientID%>').datepicker({
That way it'll pick up the rendered ID correctly everytime 这样,它将每次都能正确获取呈现的ID
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.