You must Sign In to post a response.
  • Category: JQuery

    Jquery code does not fires before postback

    I am using jquery plugin for pop up calendar in asp.net page. When the page loads, it does not fires on focus event of corresponding textbox.

    But, after postback the jquery calendar pop up works finely.

    Please tell me the reason and solution for this.

    Sample code:

    <script src="Scripts/jquery-3.1.1.js" type="text/javascript"></script>
    <script src="Scripts/jquery-ui.js" type="text/javascript"></script>
    <link href="Scripts/jquery-ui.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript">

    $(document).ready(function () {
    $("#txtDob").focus(function () {
    $("#txtDob").datepicker({
    dateFormat: "dd/mm/yy", changeMonth: true, changeYear: true
    });
    });
    });
    </script>

    <asp:TextBox ID="txtDob" runat="server"></asp:TextBox>
  • #769324
    Hi Jayesh,

    Replace your script with below one:

    <script type="text/javascript">
    $(document).ready(function () {
    $("#txtDob").datepicker({
    dateFormat: "dd/mm/yy", changeMonth: true, changeYear: true
    });
    });
    </script>

    It will work.

    Cheers :)

    Thanks!
    Anjali Bansal

    ~Give your best and lead the world


  • Sign In to post your comments