Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
jQuery datePicker is working very fine in my application. But when I use AJAX update panel. It won't work. What might be the reason? I think since the Textbox is inside ContentTemplate its ID might not be available for jQuery. Just wanted to know why it is not working inside updatepanel?
Posted
Updated 25-Dec-18 18:34pm

In your UpdatePanel add css class on your test box

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
           <asp:TextBox ID="TextBox1" runat="server" CssClass="classTarget"></asp:TextBox>
           ..... 
        </ContentTemplate>
</asp:UpdatePanel>
In your script add this code

   <script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.1.js">
   </script>
   <script type="text/javascript">
        $(document).ready(function() {
            Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

            function EndRequestHandler(sender, args) {
                $('.classTarget).datepicker({ dateFormat: 'dd-mm-yy' });
            }

        });
    </script>  
 
Share this answer
 
 
Share this answer
 
Comments
Karthik Holla 4-Jun-14 12:01pm    
Thank You
Yeah that might be the issue. You can know about this issue in a Developer Tool Console Window.

For example, you can try FireBug in Firefox and see if there are any issues or not.

I that case, try to get the ClientId like below and invoke the datepicker function.
JavaScript
$('#<%= txtDate.ClientID %>').datepicker();
 
Share this answer
 
Comments
Karthik Holla 4-Jun-14 12:02pm    
Thank you... But $('#<%= txtDate.ClientID %>').datepicker(); also didn't worked for me.

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



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