我如何在ASP MVC中创建数据贴纸 [英] How I make datapicker in ASP MVC

查看:52
本文介绍了我如何在ASP MVC中创建数据贴纸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我正在使用ASP MVC,我想在我的日期字段中添加 Datepicker Jquery插件,但它不起作用。

虽然我安装了插件并添加到BundleConfig中。



这是字段HTML:



Hello,
I am using ASP MVC and I want to add a Datepicker Jquery Plugin to my Date Field but it doesn't work.
Although I installed the plugin and added in BundleConfig.

This is the fields HTML :

@{
    var fromDate = ViewBag.fromDate as DateTime?;
    var toDate = ViewBag.toDate as DateTime?;
}

@using (Html.BeginForm("FiltredDate", "Home", FormMethod.Get))
{
    <div>From Date: @Html.TextBox("fromDate", fromDate == null ? "" : string.Format("{0:dd MMM yyy}", fromDate.Value), new { @class = "DatePicker" })</div>
    <div>To Date: @Html.TextBox("toDate", toDate == null ? "" : string.Format("{0:dd MMM yyy}", toDate.Value), new { @class = "DatePicker" })</div>
    <input type="submit" value="Search" />
}





这是剧本:



and this is The script :

@section Scripts {

    @Scripts.Render("~/bundles/jqueryui")
    @Styles.Render("~/Content/cssjqryUi")

    <script type="text/javascript">

     $(document).ready(function () {
         $('input[type=datetime]').datepicker({
             dateFormat: "dd/M/yy",
             changeMonth: true,
             changeYear: true,
             yearRange: "-60:+0"
         });

     });
    </script>

}





我的尝试:



我尝试了太多的脚本,但我没有得到解决方案,虽然另一个Datapicker在我的项目中完美地工作



What I have tried:

I tried too much scripts but I didnt get a solution although another Datapicker work perfectly in my project

推荐答案

document )。ready( function (){
(document).ready(function () {


' input [type = datetime]')。datepicker({
dateFormat: dd / M / yy
changeMonth: true
changeYear: true
yearRange: - 60:+0
});

});
< / script>

}
('input[type=datetime]').datepicker({ dateFormat: "dd/M/yy", changeMonth: true, changeYear: true, yearRange: "-60:+0" }); }); </script> }





我的尝试:



我尝试了太多的脚本,但我没有得到解决方案,虽然另一个Datapicker在我的项目中完美运行



What I have tried:

I tried too much scripts but I didnt get a solution although another Datapicker work perfectly in my project



这篇关于我如何在ASP MVC中创建数据贴纸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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