Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
HTML
<link type="text/css" href="css/ui-lightness/jquery-ui-1.8.19.custom.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.19.custom.min.js"></script>
<script type="text/javascript">

    $(function () {
        debugger;
        $("#<%= txtCashAmt.ClientID %>").datepicker({
            changeMonth: true,
            changeYear: true,
            yearRange: '1970:2012'
          
        });
    });
</script>
<style type="text/css">
.ui-datepicker { font-size:8pt !important}
</style>



ASP.NET
<div>
   <asp:TextBox ID="txtCashAmt" runat="server" CssClass="date"></asp:TextBox>
   </div>


What I have tried:

I want to add this datepicker function in my webform which has masterpage.But the javascript function is not working with this textbox.though it works fine with <html> tag but how i can use it with asp.net form with masterpage.Please Help!
Posted
Updated 13-Sep-16 14:25pm
Comments
The Praveen Singh 1-Sep-16 3:42am    
check id of your textbox after inspecting in master page this will be changed as text box id, master page appends something like this:-ctl00$cpMainContent$ check and change in your case.
F-ES Sitecore 12-Sep-16 9:38am    
Are both of those code snippets on the master page? Both on content? One on master and one on content?
Member 10549697 13-Sep-16 4:40am    
no.both are on different page.

in client side (markup view): , it rerquires to repainted each time after Prerendered stage, (simply do it on active form , not master form )

function pageLoad()
{
$(function(){
$("#<%= txtCashAmt.ClientID %>").datepicker({
dateFormat:"dd/MM/yyyy"

});

});
}
 
Share this answer
 
v2
Comments
Member 10549697 13-Sep-16 23:50pm    
Yes.This worked.Thank You!
How about if you use the class name as the selector? For example:

JavaScript
$(function () {
        $('.date').datepicker({
            changeMonth: true,
            changeYear: true,
            yearRange: '1970:2012'
          
        });
    });
 
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