0

I want to date picker widget for my view in ASP.net mvc project.here i created a java script as mentioned below but i could not able to get the date picker when i run the application. kindly help me.

java script used

$(document).ready(
  function () {$("#datepicker").mdatepicker({
          changeMonth: true,
          changeYear: true       }); }  

html code for view :

<head>
    <script type="text/javascript" src="@Url.Content("~/Scripts/jquery-1.8.2.js")">
    </script>
<script type="text/javascript" src="@Url.Content("~/Scripts/jquery-ui-1.8.24.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/JavaScriptdatpickr.js")"></script>

<div class="editor-label" name="datepicker" id="datepicker">
        @Html.LabelFor(model => model.Registereddate)
    </div>
    <div class="editor-field" name="datepicker" id="datepicker">
        @Html.EditorFor(model => model.Registereddate)
        @Html.ValidationMessageFor(model => model.Registereddate)
    </div>

2 Answers 2

1

There is nothing called 'mdatepicker' change this $("#datepicker").mdatepicker to this $("#datepicker").datepicker and instead of applying datepicker on div apply on #Registereddate as shown :-

$(document).ready(function () {
   $("#Registereddate").datepicker({
      changeMonth: true,
      changeYear: true      
   });
});
Sign up to request clarification or add additional context in comments.

12 Comments

i tried both of your suggestions,but it is not working sadly.Kindly help further to have the date picker in my page.
@ramki_ramakrishnan...just change @Html.EditorFor(model => model.Registereddate) with @Html.TextBoxFor(model => model.Registereddate) and try..
i Don't know,its still not working.i have changed it to TextBox,but its still not working.
@ramki_ramakrishnan...just press f12 in browser and see in console tab ..if its showing some error??
you are really awesome,there are two console errors captured.
|
0

Try below code if you want to bind datepicker value to Registerddate field:

$(function() {
  $('#Registereddate').datepicker({
    changeMonth: true,
    changeYear: true
  });
});

2 Comments

sorry it is not working out for me .could you please help me little further to resolve my problem.
@ramki_ramakrishnan yes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.