为什么它不显示MVC 4中的日期和时间选择器 [英] why it doesnt display Date and time picker in MVC 4

查看:248
本文介绍了为什么它不显示MVC 4中的日期和时间选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个MVC项目,我很新。我有一个具有日期时间属性的创建视图。



在Html中,它只显示一个简单的datetime属性文本框。如何使日期和时间选择器?而且,这里是我的HTML代码...

 < div class =form-group> 
@ Html.LabelFor(model => model.CreatedTime,htmlAttributes:new {@class =control-label col-md-2})
< div class =col-md- 10 datetimepicker>
@ Html.EditorFor(model => model.CreatedTime,new {htmlAttributes = new {@class =form-control}})
@ Html.ValidationMessageFor(model => model.CreatedTime ,,新的{@class =text-danger})
< / div>
< / div>

,我的模型类就像下面

  public partial class AntsoftCrmProjectTransaction 
{
public int Id {get;组; }
public int ProjectId {get;组; }
public int MinutesSpent {get;组; }
public string ProblemDescription {get;组; }
public bool ProblemIsFixed {get;组; }
public string ProblemResult {get;组; }
public string CurrentlyInCharge {get;组; }
public int SupportId {get;组; }
public int UserId {get;组; }
public System.DateTime CreatedTime {get;组;


解决方案

您将需要某种类型的HTML控件。

 < input type =date'

在某些浏览器中有支持,但根据您的浏览器和版本有限,仅在HTML5中支持。



您的最佳解决方案是找到类似于 jquery date和时间选择器。使用它,并添加一些脚本以允许用户选择日期时间。


I am creating an MVC project, I am very new to it. I have Create View which has a datetime propery.

In Html, it just displays a simple textbox for datetime property. How can I make it Date and Time picker? And, here is my HTML code below...

<div class="form-group">
        @Html.LabelFor(model => model.CreatedTime, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10 datetimepicker">
            @Html.EditorFor(model => model.CreatedTime, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.CreatedTime, "", new { @class = "text-danger" })
        </div>
    </div>

and my model class is like below

public partial class AntsoftCrmProjectTransaction
{
    public int Id { get; set; }
    public int ProjectId { get; set; }
    public int MinutesSpent { get; set; }
    public string ProblemDescription { get; set; }
    public bool ProblemIsFixed { get; set; }
    public string ProblemResult { get; set; }
    public string CurrentlyInCharge { get; set; }
    public int SupportId { get; set; }
    public int UserId { get; set; }
    public System.DateTime CreatedTime { get; set; }

解决方案

You will need some type of HTML control for that.

<input type="date"' 

has support in some browsers but it is limited depending on your browser and version and is only supported in HTML5.

Your best solution is to find something like the jquery date and time picker. Use that and add some script to allow the user to pick the date time.

这篇关于为什么它不显示MVC 4中的日期和时间选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆