user1778868
user1778868

Reputation: 19

ken ui datepicker

I have a kendo ui datepicker and I want my selected date should be displayed in a label. I want to bind the selected date to a label.What code i have to add in a my .cs page?

 <script type="text/javascript">
           $(document).ready(function() {
                $("#date").kendoDatePicker();
           });
 </script>     
</head>
<body>
<form id="form1" runat="server">
        <div  style="width: 155px;">
            <input id="date" />
        </div>
       <asp:Label ID="lblDate" runat="server" Text="Label"></asp:Label>
</form>
</body> 

Upvotes: 1

Views: 488

Answers (1)

Aristos
Aristos

Reputation: 66641

Change the <input id="date" /> to asp.net control eg:

<asp:TextBox ID="txtDate" runat="server" ></asp:TextBox>

and then get the rendered id of the text box as:

$("#<%=txtDate.ClientID%>").kendoDatePicker();

The asp:label is not help here, meaning is not post back the value that you get of the date. On code behind you read the value of the text box using the txtDate.Text

How ever if you actually wont to place the value on the label you can use the change of the kendo date picker as:

<script type="text/javascript">
   $(document).ready(function() {
        $("#date").kendoDatePicker({
            change: function(e) {
                $("#<%=lblDate.ClientID%>").text($("#date").val());
            }
        });                
   });
 </script> 

Upvotes: 2

Related Questions