JQuery datepicker onSelect calling Url.Acion
again bit new to Jquery!
Have the following script and action. The action is being called ok but the id is always empty.
Thanks
<script type="text/javascript">
$(function() {
$('#datepicker').datepicker({
dateformat: 'yy-mm-dd',
inline: true,
onSelect: function(date, inst) {
$('#diary img').attr(
'src',
'&开发者_Python百科lt;%= Url.Action("Image") %>?id=' + date.toString());
}
});
});
</script>
public ActionResult Image(string id)
{
if (!string.IsNullOrEmpty(id))
{
}
}
Use .asString() instead. That's the method the author of datePicker uses. credits to: JQuery Datepicker returned Date object type
Managed to get it working by playing around a bit.
<script type="text/javascript">
$(function() {
$('#datepicker').datepicker({
inline: true,
onSelect: function() {
var date = $('#datepicker').datepicker('option', 'dateFormat', 'yy-mm-dd');
$('#diary img').attr(
'src',
'<%= Url.Action("Image") %>/' + date.val().toString());
}
});
});
</script>
精彩评论