Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
hi,


Im newer to ASP.Net . I have an problem in loading DatePicker in my ASP.Net(C#) project. Its not even shows errors like "Cannot load Script".... its just remains static.

My code is below... Please help me out


XML
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<link href="../../StyleSheets/_Scripts/smoothness/jquery-ui-1.7.1.custom.css" rel="stylesheet" type="text/css" />

    <script src="../../StyleSheets/_Scripts/jquery-1.3.2.min.js" type="text/javascript"></script>

    <script src="../../StyleSheets/_Scripts/jquery-ui-1.7.1.custom.min.js" type="text/javascript"></script>

    <script type="text/javascript">
        $(function() {
         $("#txt_AppointDate").datepicker({ dateFormat: 'dd/mm/yy', showSpeed: 'fast' });
        });
       </script>

XML
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="Adminmaster" Runat="Server">
<strong>Appointment Date :</strong>
          <asp:TextBox ID="txt_AppointDate" runat="server"></asp:TextBox>



Am i need to include anything else???
Please guide me....
Posted

Actually here the problem is 'Master Page with JQuery', Control Id's are Changed when the page is rendered(if you used Master Page). I think you need use Control.ClientID Property.
Try this. it will works.
<script type="text/javascript">
        $(function() {
         $("#<%=txt_AppointDate.ClientID%>").datepicker({ dateFormat: 'dd/mm/yy', showSpeed: 'fast' });
        });
       </script>
 
Share this answer
 
Comments
J.Karthick 29-Jun-11 11:36am    
Thanks a lot....You saved me.... :D
TweakBird 29-Jun-11 11:39am    
Welcome. Happy coding.
It looks like you are attempting to set your function too soon (in other words, before the document has fully loaded). Try changing it to this:
JavaScript
$(document).ready(function() {
  $("#txt_AppointDate").datepicker({ dateFormat: 'dd/mm/yy', showSpeed: 'fast' });
});
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900