开发者

how to implement datepicker in asp.net using jquery?

    <script src="<%=("../Scripts/jquery-1.6.1.min.js") %>" type="text/javascript" />
   <script src="<%=("../Scripts/jquery-datePicker.js") %>" type="text/javascript" /&开发者_StackOverflow社区gt;

<script type="text/javascript">

    $(function() {

     $("#txtDate").datepicker();       

    });   

   </script>

I have used this code but it doesnot show me the popup calender on click on textbox. what can be the problem. it doesnot give any error.


Perhaps you should use the document.ready function

$(document).ready(function() {
 $("#txtDate").datepicker();       
});


why not set path directly? and close script tag with this </script>

<script src="../Scripts/jquery-1.6.1.min.js" type="text/javascript" ></script>
<script src="../Scripts/jquery-datePicker.js" type="text/javascript" ></script>

Use ClientID for server control

<script type="text/javascript">

    $(function() {

     $("#<%= txtDate.ClientID %>").datepicker();       

    });   

   </script>

you can also use ready function

<script type="text/javascript">
$(document).ready(function() {
 $("#<%= txtDate.ClientID %>").datepicker();       
});
</script>

if ID selector doesn't work then use class selector it is good for ASP.NET server control

<asp:TextBox ruat="server" ID="txtDate" CssClass="DateField"></asp:TextBox>

<script type="text/javascript">
    $(document).ready(function() {
     $(".DateField").datepicker();       
    });
    </script>


ID of ASP.NET server control is different than that of the normal HTML ID. So if you are using a Server control, then run your code, open the page source, get the ID that is displayed in the page source and use this ID instead of txtDate.

Also use

$(document).ready(function() { $("#<id>").datepicker(); });
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜