如何在MVC 4中创建一个datepicker [英] How to create a datepicker in MVC 4

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

问题描述

如何在MVC 4中创建一个datepicker。我使用了下面的代码,但是没有用。谁能告诉我下面可能出现的问题。在此先感谢:)



DateTime.cshtml(EditorTemplates文件夹)



@model DateTime?

@ Html.TextBox(,(Model.HasValue?Model.Value.ToString(dd / MM / yyyy):string.Empty),new {@class =date})< br $> b $ b

Edit.cshtml



 <   script     src   = 〜/ Scripts / jquery-1.8.2.min.js >  <   / script  >  
< script src = 〜/脚本/ jQuery的ui.min.js > < / script >
< link href = 〜/ Content / Site.css rel < span class =code-keyword> = stylesheet / >
< link href = 〜/ Content / themes / base / jquery.ui.all.css rel = stylesheet / >

< script type = text / javascript >
$(document).ready(function(){
$(input:text.date)。datepicker(
{
dateFormat:dd / mm / yy
});
});
< / script >





调试工具说datepicker不是函数

解决方案

(document).ready(function(){


(input:text.date)。datepicker(
{
dateFormat:dd / mm / yy
});
});
< / script >





调试器工具说datepicker不是函数


hi,



查看以下链接设置datepicker:



https://jqueryui.com/datepicker/ [ ^ ]

How to create a datepicker in MVC 4. I have used the below code and is not working. Can anyone please tell me what might went wrong below. Thanks in advance :)

DateTime.cshtml (EditorTemplates folder)

@model DateTime?
@Html.TextBox("", (Model.HasValue ? Model.Value.ToString("dd/MM/yyyy") : string.Empty), new { @class = "date" })

Edit.cshtml

<script src="~/Scripts/jquery-1.8.2.min.js"></script>
<script src="~/Scripts/jquery-ui.min.js"></script>
<link href="~/Content/Site.css" rel="stylesheet" />
<link href="~/Content/themes/base/jquery.ui.all.css" rel="stylesheet" />

<script type="text/javascript">
    $(document).ready(function () {
        $("input:text.date").datepicker(
        {
            dateFormat: "dd/mm/yy"
        });
    });
</script>



Debugger tools says datepicker is not a function

解决方案

(document).ready(function () {


("input:text.date").datepicker( { dateFormat: "dd/mm/yy" }); }); </script>



Debugger tools says datepicker is not a function


hi,

check below link to set datepicker:

https://jqueryui.com/datepicker/[^]


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

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