Click here to Skip to main content
15,891,633 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i m trying to call jquery on below control
HTML
<input type="text" name="hearingDate1" id="hearingDate1" size="8" class="form-control" />

but its not working due to update panel.
if i remove update panel then its working fine.

What I have tried:

JavaScript
<script type="text/javascript">

        $(document).ready(function (e) {
            $("#clockpick,#hearingTime").clockpick({
                valuefield: 'hearingTime'
            });
            $('#hearingDate').datepick({ firstDay: 1, dateFormat: 'dd/mm/yyyy', defaultDate: false, selectDefaultDate: true,
                minDate: '0', maxDate: '+40d',
                renderer: $.extend({}, $.datepick.defaultRenderer,
        { picker: $.datepick.defaultRenderer.picker.
            replace(/\{link:clear\}/, '{button:clear}').
            replace(/\{link:close\}/, '{button:close}')
        }),
                showTrigger: '#imgDate'
            });
        });

        $(document).ready(function (e) {
            $("#clockpick1,#hearingTime1").clockpick({
                valuefield: 'hearingTime1'
            });
            $('#hearingDate1').datepick({ firstDay: 1, dateFormat: 'dd/mm/yyyy', defaultDate: false, selectDefaultDate: true,
                minDate: '0', maxDate: '+40d',
                renderer: $.extend({}, $.datepick.defaultRenderer,
        { picker: $.datepick.defaultRenderer.picker.
            replace(/\{link:clear\}/, '{button:clear}').
            replace(/\{link:close\}/, '{button:close}')
        }),
                showTrigger: '#imgDate1'
            });
        });

    </script>





<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" >
<contenttemplate>



<asp:Label ID="lblreqdetails" runat="server" Text="Request Details:">



<div class="" runat="server" id="divSummonforparties" visible="false">




*

Enter Date and Time:


<input type="text" name="hearingDate1" id="hearingDate1" size="8" class="form-control" />

<img src="../Images/calendar.gif" alt="popup1" id="imgDate1" class="trigger datepick-trigger" />



<input type="text" name="hearingTime1" id="hearingTime1" size="8" style="margin-left: 20px"
class="form-control" />


<img id="clockpick1" width="20" height="20" src="../Images/clock.gif" alt="pop1" />




<div class="row" runat="server" id="divReschedule" visible="false">





*

Enter Date and Time:


<input type="text" name="hearingDate" id="Text1" size="8" class="form-control" />

<img src="../Images/calendar.gif" alt="popup1" id="img1" class="trigger datepick-trigger" />



<input type="text" name="hearingTime" id="Text2" size="8" style="margin-left: 20px"
class="form-control" />


<img id="Img2" width="20" height="20" src="../Images/clock.gif" alt="pop1" />







<asp:Button ID="btn_submit" runat="server" Text="Submit" OnClick="btn_submit_Click"
CssClass="btn btn-success" />


<triggers> <asp:PostBackTrigger ControlID="btn_submit" />


Posted
Updated 22-Aug-16 23:33pm
v5
Comments
Rajeev Jayaram 23-Aug-16 5:36am    
Does it work for the first time?

Format the code in your question properly, and also try and only show the relevant bits.

Regardless, your issue is probably because you set the date picker on an element using $(document).ready, but when the update panel fires it destroys and re-creates the elements inside it so the element your date picker was attached to is gone, replaced with something that looks the same, but doesn't have your date picker attached.

Rather than init your date picker using document ready, use the script manager and pageLoad;

How to run javascript after updatepanel execution completed | The ASP.NET Forums[^]
 
Share this answer
 
v2
Comments
manishss 23-Aug-16 4:48am    
Now i have formatted the code kindly check Mr F-ES Sitecore and help me
F-ES Sitecore 23-Aug-16 5:06am    
As I said, use pageLoad rather than $(document).ready to attach your date picker. The code in the link shows what you have, and how you need to change it.
manishss 23-Aug-16 6:53am    
Thanks F-ES Sitecore. working fine now
Does it work for the first time? If so, after the 'update panel' updates for the first time all events are unsubscribed. Re-subscribe using the PageRequestManager which will be available, because you have the update panel in the page.

For more info, see this Sys.WebForms.PageRequestManager endRequest Event[^]
 
Share this answer
 
Comments
manishss 23-Aug-16 6:54am    
its not working for the first time also.

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