Ok, so I'm new to ASP.NET MVC and JQuery.
I have followed the following example to the letter, and I'm not able to get the datepicker working:
http://codesprouts.com/post/Creating-A-DatePicker-Extension-In-ASPNet-MVC.aspx
Can anyone tell me if there are any ticks or gotchas with this?
Bernard.
First, we need to link the CSS into our layout. Then, we link the JS file into our layout at the bottom line of code. After that, we try to assign the format of our input in class "datepicker". Then, we add another class in Add cshtml.
Use jquery hosted by google.
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"> </script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/jquery-ui.min.js"> </script>
You will also need to link to your desired css.
$().ready(function() { $('#from').datepicker({ dateFormat:'yy-mm-dd' }); }); <html> ... <input id="from" class="date-field" name="from" type="text" >
This blog post provides an excellent overview of integrating the jQuery datepicker into a MVC 3 site.
Some of other samples that I could find were focused on MVC1 and 2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With