Set MKB TimePicker time using JavaScript

Last Reply one year ago By dharmendr

Posted one year ago

I am using the MKB.TimePicker control in my aspx page. I want to set the time using Javascript. Can you share me the code snippet

You are viewing reply posted by: dharmendr one year ago.
Posted one year ago

Hi suraj@123,

Using the below article i have created the example.

TimePicker control in ASP.Net with example

Check this example. Now please take its reference and correct your code.


<%@ Register Assembly="TimePicker" Namespace="MKB.TimePicker" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
    <script type="text/javascript">
        function SetTime() {
            var timeSelector = document.getElementById("timeSelector");
            var inputs = timeSelector.getElementsByTagName("input");
            if (inputs.length === 6) {
                inputs[0].value = "04";
                inputs[2].value = "10";
                inputs[5].value = "PM";
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    <cc1:TimeSelector ID="timeSelector" runat="server">
    <br />
    <input type="button" name="setName" value="Set Time" onclick="SetTime()" />
    <br />
    <br />
    <asp:Button ID="btnSubmit" runat="server" Text="Get Time" OnClick="GetTime" />



protected void GetTime(object sender, EventArgs e)
    DateTime time = DateTime.Parse(string.Format("{0}:{1}:{2} {3}", timeSelector.Hour, timeSelector.Minute, timeSelector.Second, timeSelector.AmPm));
    ClientScript.RegisterStartupScript(this.GetType(), "time", "alert('Selected Time: " + time.ToString("hh:mm:ss tt") + "');", true);


Protected Sub GetTime(sender As Object, e As EventArgs)
    Dim time As DateTime = DateTime.Parse(String.Format("{0}:{1}:{2} {3}", timeSelector.Hour, timeSelector.Minute, timeSelector.Second, timeSelector.AmPm))
    ClientScript.RegisterStartupScript(Me.[GetType](), "time", "alert('Selected Time: " + time.ToString("hh:mm:ss tt") + "');", True)
End Sub