Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
here i am using master control.but it is not working properly.what is the error


asp.code

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

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

    <link href="css/ui-lightness/jquery-ui-1.8.19.custom.css" rel="stylesheet" />
    <script src="js/jquery-1.7.2.min.js"></script>
    <script src="js/jquery-ui-1.8.19.custom.min.js"></script>


    <script type="text/javascript">
        $(function () {
            $("#txtDate").datepicker();
        });
</script>
<style type="text/css">
.ui-datepicker { font-size:8pt !important}
</style>


</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">


    <div class="demo">
<b>Date:</b> <asp:TextBox ID="txtDate" runat="server"/>
</div>



</asp:Content>
Posted

Try this :

JavaScript
$(function () {
    $('#<%=txtDate.ClientID %>').datepicker();
});
 
Share this answer
 
v2
Comments
Member 10918596 5-Dec-14 23:49pm    
not working....
King Fisher 5-Dec-14 23:59pm    
show your Master Page Content
The 'txtDate' control is in the ContentPlaceHolder1, so to access it:
$("#ContentPlaceHolder1_txtDate").datepicker();
 
Share this answer
 
v2
Comments
Member 10918596 6-Dec-14 2:03am    
i changed but not working

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

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="js/jquery-ui-1.8.19.custom.min.js" type="text/javascript"></script>
<link href="css/ui-lightness/jquery-ui-1.8.19.custom.css" rel="stylesheet" />

<script type="text/javascript">
$(function () {
$("#ContentPlaceHolder1_txtDate").datepicker();

});
</script>
<style type="text/css">
.ui-datepicker {
font-size: 8pt !important;
}
</style>



<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">


<span style="color:gray;">dd/mm/yyyy</span><br />
<asp:TextBox ID="txtDate" runat="server"/>
1. add the datetime picker js file and add link below other js links (eg:<script src="../js/jquery.ui.datepicker-en-GB.js" type="text/javascript"></script>)


2.the above solution ie,

$(function () {
$('#<%=txtDate.ClientID %>').datepicker();
});

will works .. or in in your browser right click on text and take inspect element then you can see the correct textbox id ,
 
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