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.Set DateTime in DateTimePicker on Button Click using AngularJS in ASP.Net MVC<p>Hi <a class="username" rel="mahesh213"> mahesh213</a>,</p> <p>Check this example. Now please take its reference and correct your code.</p> <p><strong><span style="text-decoration: underline;">Controller</span></strong></p> <pre class="brush: csharp">public class HomeController : Controller { // GET: /Home/ public ActionResult Index() { return View(); } public JsonResult GetAll() { return Json(Employees(), JsonRequestBehavior.AllowGet); } public JsonResult getempByNo(int id) { Employee employee = Employees().Where(x =&gt; x.Id == id).FirstOrDefault(); return Json(employee, JsonRequestBehavior.AllowGet); } public List&lt;Employee&gt; Employees() { List&lt;Employee&gt; employees = new List&lt;Employee&gt;(); employees.Add(new Employee { Id = 1, Date = new DateTime(2019, 08, 10, 13, 23, 43) }); employees.Add(new Employee { Id = 2, Date = new DateTime(2019, 08, 12, 23, 23, 05) }); employees.Add(new Employee { Id = 3, Date = new DateTime(2019, 08, 15, 01, 30, 01) }); return employees; } public class Employee { public int Id { get; set; } public DateTime Date { get; set; } } }</pre> <p><strong><span style="text-decoration: underline;">View</span></strong></p> <pre class="brush: html">&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head runat="server"&gt; &lt;title&gt;Index&lt;/title&gt; &lt;link rel="stylesheet" type="text/css" href="../../angularjs-datetime-picker.css" /&gt; &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" /&gt; &lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.9/angular.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="../../angularjs-datetime-picker.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; var app = angular.module('MyApp', ['angularjs-datetime-picker']) app.controller('MyController', function ($scope, $http, $window, myService, $filter) { GetEmployees(); function GetEmployees() { $scope.employees = []; $http({ method: 'Get', url: '/Home/GetAll' }).success(function (data, status, headers, config) { $scope.employees = data; }).error(function (data, status, headers, config) { $scope.message = 'Unexpected Error'; }); } function ConvertJsonDateToDateTime(date) { var parsedDate = new Date(parseInt(date.substr(6))); var tzoffset = (new Date(parsedDate)).getTimezoneOffset() * 60000; var localISOTime = (new Date(parsedDate - tzoffset)).toISOString().substring(0, 19).replace('T', ' '); return localISOTime; } $scope.Edit = function (e) { var getData = myService.getemps(e.Id); getData.then(function (s) { $scope.e = s.data; $scope.Id = e.Id; $scope.Date = ConvertJsonDateToDateTime(e.Date); }, function (msg) { alert(msg.data); $scope.msg = msg.data; }); $scope.apply(); } }); app.service("myService", function ($http) { this.getemps = function (Id) { var response = $http({ method: "post", url: "/home/getempByNo", params: { id: JSON.stringify(Id) } }); return response; } }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div ng-app="MyApp" ng-controller="MyController"&gt; Date TimePicker:&lt;input datetime-picker date-format="yyyy-MM-dd HH:mm:ss" ng-model="Date" /&gt; &lt;br /&gt; &lt;div&gt; &lt;table class="table table-bordered table-hover table-striped"&gt; &lt;tr&gt; &lt;th&gt;Id&lt;/th&gt; &lt;th&gt;Date&lt;/th&gt; &lt;th&gt;&amp;nbsp;&lt;/th&gt; &lt;/tr&gt; &lt;tbody ng-repeat="e in employees"&gt; &lt;tr&gt; &lt;td&gt;{{e.Id}}&lt;/td&gt; &lt;td&gt;{{e.Date}}&lt;/td&gt; &lt;td&gt;&lt;a ng-click="Edit(e)" href=""&gt;Edit&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt;</pre> <p><strong><span style="text-decoration: underline;">Screenshot</span></strong></p> <p><img src="https://i.imgur.com/0cRkkc0.gif" alt="" width="346" height="388" /></p>https://www.aspforums.net:443/Threads/167006/Set-DateTime-in-DateTimePicker-on-Button-Click-using-AngularJS-in-ASPNet-MVC/https://www.aspforums.net:443/Threads/167006/Set-DateTime-in-DateTimePicker-on-Button-Click-using-AngularJS-in-ASPNet-MVC/Wed, 14 Aug 2019 04:53:54 GMT