在mvc5中使用jquery的datepicker [英] datepicker using jquery in mvc5

查看:55
本文介绍了在mvc5中使用jquery的datepicker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是mvc5的新手..我试过简单的appl。在文本框聚焦时显示datepicker对话框。但它不工作。请帮助我解决问题..





这是查看:



 @ {
ViewBag.Title =Index;
}

< h2 > 索引< / h2 >


< script src = 〜/ Scripts / bootstrap-datepicker.js > < / script >
< ; link href < span class =code-keyword> = 〜/ Content / bootstrap-datepicker.css rel = stylesheet / >

< 输入 类型 = text class = dp / >

< script 类型 = text / JavaScript的 >
$(function(){
$('。dp')。datepicker();;
});

< / script >







布局页面:



 <  !DOCTYPE     html  >  
< html >
< head >
< meta charset = utf-8 / >
< meta name = viewport content = width =设备宽度,initial-scale = 1.0 >
< script src = 〜/ Scripts / modernizr-2.6.2 .js > < / script >
< script src = 〜/ Scripts / jquery-1.10.2.min.js > < / script >
< < span class =code-leadattribute> link
href = 〜/ Content / themes / ui-lightness / jquery-ui.css rel = stylesheet / >
< title > @ViewBag。标题 - 我的ASP.NET应用程序< / title > ;
@ Styles.Render(〜/ Content / css)
@ Scripts.Render(〜/ bundles / modernizr)

< / head >
< span class =code-keyword>< body >
< div class = navbar navbar-inverse navbar-fixed-top >

@ Html.Partial(_ Lo ginPartial)
< / div > ;

< div class = container正文内容 >
@RenderBody()
< hr / >
< 页脚 >
< p > ©@ DateTime.Now.Year - 我的ASP.NET应用ication < / p >
< / footer >
< / div >
@ Scripts.Render(〜/ bundles / jquery)
@ Scripts.Render(〜/ bundles / bootstrap)
@RenderSection(scripts,required: false)
< / body >
< / html >

解决方案

(function(){


('。dp ')。日期选择器();;
});

< / script >







布局页面:



 <  !DOCTYPE     html  >  
< html >
< head >
< meta charset = utf-8 / >
< meta name = viewport content = width =设备宽度,initial-scale = 1.0 >
< script src = 〜/ Scripts / modernizr-2.6.2 .js > < / script >
< script src = 〜/ Scripts / jquery-1.10.2.min.js > < / script >
< < span class =code-leadattribute> link
href = 〜/ Content / themes / ui-lightness / jquery-ui.css rel = stylesheet / >
< title > @ViewBag。标题 - 我的ASP.NET应用程序< / title > ;
@ Styles.Render(〜/ Content / css)
@ Scripts.Render(〜/ bundles / modernizr)

< / head >
< span class =code-keyword>< body >
< div class = navbar navbar-inverse navbar-fixed-top >

@ Html.Partial(_ Lo ginPartial)
< / div > ;

< div class = container正文内容 >
@RenderBody()
< hr / >
< 页脚 >
< p > ©@ DateTime.Now.Year - 我的ASP.NET应用ication < / p >
< / footer >
< / div >
@ Scripts.Render(〜/ bundles / jquery)
@ Scripts.Render(〜/ bundles / bootstrap)
@RenderSection(scripts,required: false)
< / body >
< / html >


为此,您必须在包含jquery.js后将jQuery UI脚本添加到项目中

you可以通过以下链接下载 http://jqueryui.com/download/all/ [ ^

i am new to mvc5.. i tried simple appl. to display datepicker dialog when textbox is focused. but it is not working.pls help me to fix the issue..


this is view:

@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>


<script src="~/Scripts/bootstrap-datepicker.js"></script>
<link href="~/Content/bootstrap-datepicker.css" rel="stylesheet" />

<input type="text" class="dp" />

<script type="text/javascript">
    $(function () {
        $('.dp').datepicker();;
    });

</script>




Layout page:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="~/Scripts/modernizr-2.6.2.js"></script>
    <script src="~/Scripts/jquery-1.10.2.min.js"></script>
    <link href="~/Content/themes/ui-lightness/jquery-ui.css" rel="stylesheet" />
    <title>@ViewBag.Title - My ASP.NET Application</title>
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")

</head>
<body>
    <div class="navbar navbar-inverse navbar-fixed-top">
   
                @Html.Partial("_LoginPartial")
            </div>
   
    <div class="container body-content">
        @RenderBody()
        <hr />
        <footer>
            <p>© @DateTime.Now.Year - My ASP.NET Application</p>
        </footer>
    </div>
    @Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
    @RenderSection("scripts", required: false)
</body>
</html>

解决方案

(function () {


('.dp').datepicker();; }); </script>




Layout page:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="~/Scripts/modernizr-2.6.2.js"></script>
    <script src="~/Scripts/jquery-1.10.2.min.js"></script>
    <link href="~/Content/themes/ui-lightness/jquery-ui.css" rel="stylesheet" />
    <title>@ViewBag.Title - My ASP.NET Application</title>
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")

</head>
<body>
    <div class="navbar navbar-inverse navbar-fixed-top">
   
                @Html.Partial("_LoginPartial")
            </div>
   
    <div class="container body-content">
        @RenderBody()
        <hr />
        <footer>
            <p>© @DateTime.Now.Year - My ASP.NET Application</p>
        </footer>
    </div>
    @Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
    @RenderSection("scripts", required: false)
</body>
</html>


For that you have to add jQuery UI script into your project after including jquery.js
you can download at following link
http://jqueryui.com/download/all/[^]


这篇关于在mvc5中使用jquery的datepicker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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