Jquery Datepicker not working in Master Page Using Asp.Net

Jquery Datepicker not working in Master Page

Jquery Datepicker  not working inside of master page because ContentPlaceholder strange id does not  find so put input id properly avoid this problem.


Working:

  $("input[id$='textboxDate']")

                         
                                             DEMO

                                    


                        HTML CODING

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
     <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/ui-lightness/jquery-ui.css"/>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>

     <%--NOT WORKING--%>
    <script type="text/javascript" lang="javascript">
        $(function () {
            $("#textboxDate").datepicker({
                dateFormat: 'dd/mm/yy',
            });
        });
    </script>

    <%--WORKING--%>

    <script type="text/javascript" lang="javascript">
        $(function () {

            $("input[id$='textboxDate']").datepicker({
                dateFormat: 'dd/mm/yy',
            });
        });
    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1">
    <title></title>

   
         
</head>
<body>
    <div>
 
        <table><tr><td>
            <asp:Label ID="Label1" runat="server" Text="Select Date"></asp:Label>
            </td><td>
                <asp:TextBox ID="textboxDate" runat="server"></asp:TextBox>
            </td></tr></table>
  
    </div>
</body>
</html>


</asp:Content>


Add New Master page - next add new Webform for Masterpage  -  Jquery Datetime picker input id value accept Content place holder 





Next - Textbox id for call child strange id to masterpage ContentPlaceHolder






1 comment: