标签:
1. 安装地址moment.min.js
@using Microsoft.Web.Mvc @model WebApplication1.Controllers.HomeController.HomeVm @{ Layout = "~/Views/Shared/_Layout.cshtml"; } @section Scripts{ <link href="http://netdna.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet"> <link href="~/Content/daterangepicker-bs3.css" rel="stylesheet" /> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script> <script type="text/javascript" src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script> <script src="~/Scripts/moment.js"></script> <script src="~/Scripts/daterangepicker.js"></script> <script> $(document).ready(function() { $(‘.form-control.daterange‘).daterangepicker( { format: ‘DD/MM/YYYY hh:MM:ss‘, locale: { cancelLabel: ‘Clear‘ }, timePicker: true, timePickerIncrement: 1 }); $(‘.form-control.daterange‘).on(‘cancel.daterangepicker‘, function (event, picker) { picker.element.val(‘‘); }); }); </script> } <body> <div> @TempData["datetime"] </div> @using (Html.BeginForm("Index", "Home", FormMethod.Post)) { <div class="input-group"> @Html.TextBoxFor(m => m.datetime, new { @class = "form-control daterange", @readonly = "" }) </div> <input type="submit" value="Submit" /> } </body>
public class HomeController : Controller { public class HomeVm { public string datetime { get; set; } } [HttpGet] public ActionResult Index() { return View(); } [HttpPost] public ActionResult Index(HomeVm vm) { TempData["datetime"] = vm.datetime; return View(); } }
MVC4 使用 bootstrap daterangepicker
标签:
原文地址:http://blog.csdn.net/lan_liang/article/details/43541159