Click here to Skip to main content
15,120,567 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
this is a code for calendar control in jquery.


if i add this code in .aspx page it is woking fine but if i add this code in

user control it is not working .

Let me know the solution for this.

the below is given code
XML
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
      <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
 <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script type="text/javascript" language="javascript">
    $(document).ready(function() {
        $("<%=TextBox1.clientid%>").datepicker({
            dateFormat: 'mm/dd/yy',
            buttonImage: '/images/folders/date.png',
            buttonText: 'Choose date',
            firstDay: 1,
            buttonImageOnly: true,
            showOn: 'both',
            showAnim: 'fadeIn',
            minDate: '0',
            maxDate: +30,
            onSelect: function() { $(this).trigger("onchange", null); }
        });
      });
</script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    </div>
    <div>
        <asp:TextBox id="TextBox1" runat="server" Text="" ReadOnly ="true"> </asp:TextBox>

        </div>
    </form>
</body>
</html>
Posted
Comments
thatraja 18-Apr-11 12:25pm
   
Include error message if any in your question(always).
Jonathan Cardy 18-Apr-11 16:50pm
   
There are probably numerous problems, but to get you started, "<%=TextBox1.clientid%>" is not a CSS selector - try "$('#TextBox1')"

1 solution

Try following:

<script type="text/javascript" language="javascript">
    $(document).ready(function() {
         $("#<%= TextBox1.ClientID %>").datepicker({
            dateFormat: 'mm/dd/yy',
            buttonImage: '/images/folders/date.png',
            buttonText: 'Choose date',
            firstDay: 1,
            buttonImageOnly: true,
            showOn: 'both',
            showAnim: 'fadeIn',
            minDate: '0',
            maxDate: +30,
            onSelect: function() { $(this).trigger("onchange", null); }
        });
      });
</script>


I hope the above information will be helpful. If you have more concerns, please let me know.
   
v2

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