Click here to Skip to main content
15,886,783 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
here i've given my code which i'm using inside update panel. but i'm facing error like
"Object Has no method 'datepicker'"

JavaScript
jQuery(function ($) {
           $("#<%= txtfrmdate.ClientID%>").datepicker({
               changeMonth: true,
               changeYear: true,
               showWeek: true,
               gotoCurrent: true,
               yearRange: '-70:+10',
               constrainInput: false
           });
Posted

Hello there,

Try adding this line after your DatePicker code:
JavaScript
Sys.WebForms.PageRequestManager.getInstance().add_endRequest
It'll restore your script after ajax postback.
I have modified your code slightly to achieve the solution:
JavaScript
jQuery(function ($) {
            MyDatePickerFunction();
            Sys.WebForms.PageRequestManager.getInstance().add_endRequest(MyDatePickerFunction);
            });

JavaScript
function MyDatePickerFunction()
{
   $("#<%= txtfrmdate.ClientID%>").datepicker({
                changeMonth: true,
                changeYear: true,
                showWeek: true,
                gotoCurrent: true,
                yearRange: '-70:+10',
                constrainInput: false
            });
}


Hope it helps,

good luck

Azee...
 
Share this answer
 
v2
Comments
VIP Venkatesan 1-Oct-13 3:52am    
Still facing the same problem.

Uncaught TypeError: Object #<Object> has no method 'datepicker'
Jay Tetar 4-Jun-14 1:25am    
thank you it solve my probs
Try This..

XML
<script type="text/javascript" >

$(document).ready(function () {
            Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
            Sys.WebForms.PageRequestManager.getInstance().beginAsyncPostBack();
            function EndRequestHandler(sender, args) {
                $('input[id$=txtFecha0]').datetimepicker({
                    dayOfWeekStart: 1,
                    lang: 'es',
                    step: 1,
                    ampm: true
                });
            }
        });
</script>

<asp:UpdatePanel ID="Udp_Panel" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <asp:Panel ID="Pnl" runat="server">
            <asp:TextBox ID="txtFecha0" runat="server" Width="375px" />
            <asp:Image ID="calendario" runat="server" ImageUrl="~/Images/icoCalendario.gif" />
        </asp:Panel>
    </ContentTemplate>
</asp:UpdatePanel>
 
Share this answer
 

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