Using a DateTime Picker for ASP.NET MVC 5 with Bootstrap

本文介绍如何在ASP.NET MVC应用中配置日期时间选择器。通过创建新的资源包并更新布局页面来集成moment.js和bootstrap-datetimepicker。示例代码展示了如何设置日期时间选择器的格式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Create the Bundle

Open BundleConfig.cs (located in the App_Start directory).  Add the following code:

bundles.Add(new ScriptBundle("~/bundles/datetime").Include(
    "~/Scripts/moment*",
    "~/Scripts/bootstrap-datetimepicker*"));

Update the Layout Page

Open _Layout.cshtml.  Update the code near the bottom of the page to look like this:

  @Scripts.Render("~/bundles/jquery")
  @Scripts.Render("~/bundles/bootstrap")
  @Scripts.Render("~/bundles/datetime")
  @RenderSection("scripts", required: false)
</body>
</html

<div class="container">
    <div class="row">
        <div class='col-sm-6'>
            <input type='text' class="form-control" id='datetimepicker4' />
        </div>
        <script type="text/javascript">
            $(function () {
                $('#datetimepicker4').datetimepicker(
 

        {format: 'DD/MM/YYYY' });
        </script>
    </div>
</div>
https://eonasdan.github.io/bootstrap-datetimepicker/


之前在一家公司里用过Knockout,是easyui 和 Knockout结合 的。下面的这本应该不错。 目录 前言 第一部分入门指南 第1章MVC介绍 创建第一个项目 分析HomeController 分析View 理解URL结构 小结 第2章Bootstrap介绍 默认菜单 含有下拉列表和搜索框的菜单 按钮 警告框 主题 小结 第3章Knockout.js介绍 安装Knockout.js 基本示例 何为MVVM? 创建ViewModel 小结 第4章数据库应用 Entity Framework介绍 Code First Database First 创建测试数据 小结 第二部分数据处理 第5章表的查询、排序、分页 Author查询 Author排序 Author分页 小结 第6章表单处理 在表单中集成Knockout 共享View和ViewModel 在模态框中进行删除操作 空表格 小结 第7章服务器端ViewModel 为什么要创建服务器端ViewModel? AuthorViewModel 更新Authors列表 更新Add/Edit表单 更新Delete模态框 小结 第8章Web API介绍 安装Web API 更新Authors列表 更新Authors的Add/Edit表单 小结 第三部分代码架构 第9章创建全局过滤器 Authentication过滤器 Authorization过滤器 Action过滤器 Result过滤器 Exception过滤器 Web API全局验证 用Result过滤器进行自动映射 Web API错误处理 MVC错误处理 小结 第10章添加验证与授权 Authentication概述 Authorization概述 实现一个Authentication过滤器 实现一个Authorization过滤器 小结 第11章使用Attribute定义URL路由 Attribute路由基础知识 路由前缀 路由约束 小结 第12章胖模型、瘦控制器 关注点分离 服务与行为 小结 第四部分应用实例 第13章构建购物车 购物车需求 购物车项目 JavaScript捆绑与最小化 小结 第14章构建数据模型 Code—First模型 定义DbContext并初始化数据 视图模型 小结 第15章布局实现 共享布局 购物车摘要 分类菜单 小结 第16章图书列表 主页 特色图书 按分类筛选图书 小结 第17章添加购物车 图书详情 自定义组件和自定义绑定 保存购物车项 小结 第18章更新或删除购物车 购物车详情 购物车详情上的Knockout应用 完成购物车
Bring dynamic server-side web content and responsive web design together to build websites that work and display well on any resolution, desktop or mobile. With this practical book, you’ll learn how by combining the ASP.NET MVC server-side language, the Bootstrap front-end framework, and Knockout.js—the JavaScript implementation of the Model-View-ViewModel pattern. Author Jamie Munro introduces these and other related technologies by having you work with sophisticated web forms. At the end of the book, experienced and aspiring web developers alike will learn how to build a complete shopping cart that demonstrates how these technologies interact with each other in a sleek, dynamic, and responsive web application. Build well-organized, easy-to-maintain web applications by letting ASP.NET MVC 5, Bootstrap, and Knockout.js do the heavy lifting Use ASP.NET MVC 5 to build server-side web applications, interact with a database, and dynamically render HTML Create responsive views with Bootstrap that render on a variety of modern devices; you may never code with CSS again Add Knockout.js to enhance responsive web design with snappy client-side interactions driven by your server-side web application Table of Contents Part I. Getting Started Chapter 1. Introduction to MVC Chapter 2. Introduction to Bootstrap Chapter 3. Introduction to Knockout.js Chapter 4. Working with a Database Part II. Working with Data Chapter 5. Listing, Sorting, and Paging Through Tables Chapter 6. Working with Forms Chapter 7. Server-Side ViewModels Chapter 8. Introduction to Web API Part III. Code Architecture Chapter 9. Creating Global Filters Chapter 10. Adding Authentication and Authorization Chapter 11. URL Routing Using Attributes Chapter 12. Fat Model, Skinny Controller Part IV. A Practical Example Chapter 13. Building a Shopping Cart Chapter 14. Building the Data Model Chapter 15. Implementing the Layout Chapter 16. Lists of Books Chapter 17. Adding Items to the Cart Chapter 18. Updating and Deleting Cart Items
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值