在ASP.NET上放置日期格式

问题描述

我正在图书馆管理网站上工作。我在ASP.NET中设置日期有些麻烦。

我如何让应用程序用户在创建项目时选择当前的日期格式?

Create.csshtml

   @model LibraryProject.LibraryItem

@{
    ViewBag.Title = "Create";
}

<h2>Create</h2>


    @using (Html.BeginForm()) 
    {
        @Html.AntiForgeryToken()
        
        <div class="form-horizontal">
            <h4>Book</h4>
            <hr />
            @Html.ValidationSummary(true,"",new { @class = "text-danger" })
    
    
            <div class="form-group">
                @Html.LabelFor(model => model.CategoryId,"Category",htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.DropDownList("CategoryId",null,htmlAttributes: new { @class = "form-control" })
                    @Html.ValidationMessageFor(model => model.CategoryId,new { @class = "text-danger" })
                </div>
            </div>
    
            <div class="form-group">
                @Html.LabelFor(model => model.Title,htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.Title,new { htmlAttributes = new { @class = "form-control" } })
                    @Html.ValidationMessageFor(model => model.Title,new { @class = "text-danger" })
                </div>
            </div>
    
            <div class="form-group">
                @Html.LabelFor(model => model.Author,htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.Author,new { htmlAttributes = new { @class = "form-control" } })
                    @Html.ValidationMessageFor(model => model.Author,new { @class = "text-danger" })
                </div>
            </div>
    
            <div class="form-group">
                @Html.LabelFor(model => model.Pages,htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.Pages,new { htmlAttributes = new { @class = "form-control" } })
                    @Html.ValidationMessageFor(model => model.Pages,new { @class = "text-danger" })
                </div>
            </div>
    
           
    
            <div class="form-group">
                @Html.LabelFor(model => model.IsBorrowable,htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    <div class="checkBox">
                        @Html.EditorFor(model => model.IsBorrowable)
                        @Html.ValidationMessageFor(model => model.IsBorrowable,new { @class = "text-danger" })
                    </div>
                </div>
            </div>
    
            <div class="form-group">
                @Html.LabelFor(model => model.Borrower,htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.Borrower,new { htmlAttributes = new { @class = "form-control" } })
                    @Html.ValidationMessageFor(model => model.Borrower,new { @class = "text-danger" })
                </div>
            </div>
    
            <div class="form-group">
                @Html.LabelFor(model => model.BorrowDate,htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.ValidationMessageFor(model => model.BorrowDate,"The date is created automatically.",new { @class = "text-danger" })
                </div>
            </div>
    
            <div class="form-group">
                @Html.LabelFor(model => model.Type,htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.Type,new { htmlAttributes = new { @class = "form-control" } })
                    @Html.ValidationMessageFor(model => model.Type,new { @class = "text-danger" })
                </div>
            </div>
    
            <div class="form-group">
                <div class="col-md-offset-2 col-md-10">
                    <input type="submit" value="Create" class="btn btn-default" />
                </div>
            </div>
        </div>
    }
    
    <div>
        @Html.ActionLink("Back to List","Index")
    </div>
    
    @section Scripts {
        @Scripts.Render("~/bundles/jqueryval")
    }

enter image description here

因此您可以在图像上看到,当用户创建一本书时,我想获取借阅日期,这样做的最佳方法是什么?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)