Click here to Skip to main content
15,907,395 members
Please Sign up or sign in to vote.
4.16/5 (5 votes)
See more:
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:

XML
@{
    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:

HTML
<!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>
Posted
Updated 21-Oct-14 19:41pm
v2

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/[^]
 
Share this answer
 
Fiddle[^]

This is a simple fiddle in which i have used Jquery version 1.9.*
What I think is you are missing the jquery-ui version reference.
Check the fiddle.
I hope this helps.
Thanks.
:)
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900