ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Disable Times in jQuery timepicker based on Database value using jQuery AJAX in ASP.Net<p>Hi <a class="username" rel="nauna"> nauna</a>,</p> <p>Refer below sample.</p> <p>I have used datatable for data you can fetch data from database to datatable.</p> <p><span style="text-decoration: underline;"><strong>HTML</strong></span></p> <pre class="brush: html">&lt;script type=&#34;text/javascript&#34; src=&#34;http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js&#34;&gt;&lt;/script&gt; &lt;link rel=&#34;stylesheet&#34; type=&#34;text/css&#34; href=&#34;https://cdnjs.cloudflare.com/ajax/libs/jquery-timepicker/1.10.0/jquery.timepicker.css&#34; /&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;https://cdnjs.cloudflare.com/ajax/libs/jquery-timepicker/1.10.0/jquery.timepicker.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34;&gt; $(function () { var pair = []; $.ajax({ type: &#34;POST&#34;, url: &#34;CS.aspx/GetCurrentTime&#34;, contentType: &#34;application/json; charset=utf-8&#34;, dataType: &#34;json&#34;, async: false, success: function (response) { for (var i = 0; i &lt; response.d.length; i++) { var hour = response.d[i].split(&#39; &#39;)[0].split(&#39;:&#39;)[0]; var min = parseInt(response.d[i].split(&#39; &#39;)[0].split(&#39;:&#39;)[1]) + 1; min = min &lt; 10 ? &#39;0&#39; + min : min; var ampm = response.d[i].split(&#39; &#39;)[1]; var start = response.d[i]; var end = hour + &#39;:&#39; + min + &#39; &#39; + ampm; pair.push([start, end]); } } }); $(&#39;[id*=txttimeofreservation]&#39;).timepicker({ &#39;disableTimeRanges&#39;: pair }); }); &lt;/script&gt; &lt;div&gt; &lt;asp:TextBox ID=&#34;txttimeofreservation&#34; runat=&#34;server&#34;&gt;&lt;/asp:TextBox&gt; &lt;/div&gt;</pre> <p><span style="text-decoration: underline;"><strong>Namespaces</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">using System.Data;</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Imports System.Data</pre> <p><span style="text-decoration: underline;"><strong>Code</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">[System.Web.Services.WebMethod] public static string[] GetCurrentTime() { DataTable dt = new DataTable(); dt.Columns.Add(&#34;Date&#34;); dt.Rows.Add(&#34;01:00 AM&#34;); dt.Rows.Add(&#34;02:00 AM&#34;); dt.Rows.Add(&#34;03:00 AM&#34;); dt.Rows.Add(&#34;04:00 AM&#34;); string[] result = new string[dt.Rows.Count]; for (int i = 0; i &lt; dt.Rows.Count; i++) { result[i] = dt.Rows[i][0].ToString(); } return result; }</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">&lt;System.Web.Services.WebMethod()&gt; Public Shared Function GetCurrentTime() As String() Dim dt As DataTable = New DataTable() dt.Columns.Add(&#34;Date&#34;) dt.Rows.Add(&#34;01:00 AM&#34;) dt.Rows.Add(&#34;02:00 AM&#34;) dt.Rows.Add(&#34;03:00 AM&#34;) dt.Rows.Add(&#34;04:00 AM&#34;) Dim result As String() = New String(dt.Rows.Count - 1) {} For i As Integer = 0 To dt.Rows.Count - 1 result(i) = dt.Rows(i)(0).ToString() Next Return result End Function</pre> <p><span style="text-decoration: underline;"><strong>Screenshot</strong></span></p> <p><img src="https://i.imgur.com/1WOKQMs.gif" alt="" width="247" height="320" /></p>https://www.aspforums.net:443/Threads/374491/Disable-Times-in-jQuery-timepicker-based-on-Database-value-using-jQuery-AJAX-in-ASPNet/https://www.aspforums.net:443/Threads/374491/Disable-Times-in-jQuery-timepicker-based-on-Database-value-using-jQuery-AJAX-in-ASPNet/Thu, 20 Jun 2019 04:32:49 GMT