Click here to Skip to main content
15,906,106 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
i have the following coding
ASP.NET
<%@ Page Title="" Language="C#" MasterPageFile="~/CRMTrackingUser.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="CRMTracking.Pages.Default2" EnableEventValidation="false" %>
<%@ MasterType VirtualPath="~/CRMTrackingUser.Master" %>
<asp:Content ID="Content2" ContentPlaceHolderID="CRMMainDisplayContent" runat="server"> 
<link href="../CSS/pikaday.css" rel="stylesheet" />
    <script src="pikaday.js"></script>
<script>
            var picker = new Pikaday(
            {
                field: document.getElementById('txtUDob'),
                firstDay: 1,
                minDate: new Date(2000, 0, 1),
                maxDate: new Date(2020, 12, 31),
                yearRange: [2000, 2020]
            });
        </script>
<div>
<table><tr><td>
<asp:TextBox ID="txtUDob" runat="server" CssClass="input"></asp:TextBox>
</td></tr></table>
</div>
</asp:Content>

when i put these codes in a webform it works but i the above situation nothing is happening. please figure out my problem..
Posted

Hi
Use this for getting text box object as:

field:document.getElementById('<%=txtUDob.ClientID%>'),
 
Share this answer
 
Comments
Altaful Haq 13-Aug-15 8:27am    
Can i also change the format of date entered into textbox
mbdali 15-Apr-16 14:12pm    
awesome worked..saved my day
View your web form Source code through right click on your page and click view source and look you TextBox Id "txtUDob".
I will Change because you are using Master Page. so it will be as like

"ctl00_ContentPlaceHolder1_txtUDob".

So Please user your code as like

<script>
var picker = new Pikaday(
{
field: document.getElementById('ctl00_ContentPlaceHolder1_txtUDob'),
firstDay: 1,
minDate: new Date(2000, 0, 1),
maxDate: new Date(2020, 12, 31),
yearRange: [2000, 2020]
});
</script>


Regards,
AARIF SHAIKH
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900