none
Jquery datepicker control RRS feed

  • Question

  • Hi,

    I wanted to show the datepicker control through visual webpart.I configured jquery in  my site collections.I copied 2 jquery files into layouts folder and configured in v4.master through scriptlink tag.for date picker control i use the below code in visual webpart  source.

    <script type="text/javascript" src="/_LAYOUTS/JQuery/JQuery-1.7.2.js">

     <script type="text/javascript">
        $(function () {
            $("#datepicker").datepicker();
        });
        
         $('input[type="text"][id*="datepicker"]:eq(0)').datepicker();
        
        </script>

        </script>

        

    <div class="demo">

    <asp:TextBox ID="datepicker" runat="server"></asp:TextBox>

    </div><!-- End demo -->

    After deploying it when iam trying to insert this webpart the datepicker control added successfully.But the functionality is not working when clicking on control the dates are not displayed.please help.Thanks in advance.

    Regards,

    Praveen




    Monday, June 25, 2012 8:28 PM

Answers

  • The problem is at this line

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


    you have taken a textbox with ID="datepicker" so when it renders and jquery call happens it gives a different client Id.

    The Solution:

    Replace this line with the following line..

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

    Your web control will work. 

    Try and check if there is no javascript error..

    Do not forget to mark as answer or vote as helpful if it answers your query.

    Thanks


    ajit

    Tuesday, June 26, 2012 10:01 AM
  • For to use asp. net control you should use

    $("#<%=ControlID.ClientID%>")

    as

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

    and for html control you can use as you already done.

    May this will help you.


    Ritu Ranjan

    Tuesday, June 26, 2012 10:44 AM

All replies

  • The problem is at this line

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


    you have taken a textbox with ID="datepicker" so when it renders and jquery call happens it gives a different client Id.

    The Solution:

    Replace this line with the following line..

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

    Your web control will work. 

    Try and check if there is no javascript error..

    Do not forget to mark as answer or vote as helpful if it answers your query.

    Thanks


    ajit

    Tuesday, June 26, 2012 10:01 AM
  • For to use asp. net control you should use

    $("#<%=ControlID.ClientID%>")

    as

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

    and for html control you can use as you already done.

    May this will help you.


    Ritu Ranjan

    Tuesday, June 26, 2012 10:44 AM
  • you can replace it with another one:

    $("input[id*='datepicker']").datepicker();

    Thursday, June 28, 2012 7:36 AM