Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Jquery datepicker is not showing please help

$
0
0

Here is my code. I have given my model, controller, view please help

Model
public class WeatherVM
    {
        public int LocationId { get; set; }
        public DateTime ForcastDate { get; set; }
        public WeatherLocation WeatherLocation;
        public IEnumerable<Weather> Weather { get; set; }
        public IEnumerable<SelectListItem> Locations { get; set; }

    }
Controller

 public async Task<IActionResult> Index()
        {
            IEnumerable<WeatherLocation> locList = _unitOfWork.Location.GetAll();

            WeatherVM weatherVM = new WeatherVM()
            
            {
                
                Locations = locList.Select(i => new SelectListItem
                {
                    Text = i.LocationName,
                    Value = i.LocationId.ToString()
                })
            };
            weatherVM.ForcastDate= DateTime.Now;

            //var Weather = new List<Weather>();
            //var weatherList = await _weatherRepository.GetWeatherAsync();

            return View(weatherVM);
        }

View

@model myWeather.ViewModels.WeatherVM
@{
    ViewData["Title"] = "Index";
}<h1>Forcast Weather </h1><form asp-controller="Forcast" asp-action="Index" method="post"><div class="form-group"><div class="row"><div class="col-sm-2"><label asp-for="Locations">Locations</label></div><div class="col-4">
                @Html.DropDownListFor(m => m.WeatherLocation.LocationId, Model.Locations, "-Select a Category",
                new { @class = "form-control" })</div></div></div><div class="form-group row"><div class="col-sm-2"><label asp-for="ForcastDate"></label></div><div class="col-4"><div class='input-group date' id='startDatePicker'><input type='text' id="forcastDate"  asp-for="ForcastDate" readonly class="form-control" /><span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span></div><span asp-validation-for="ForcastDate" class="text-danger"></span></div></div></form><script type="text/javascript">$(document).ready(function () {
        KeyHandler();$("#startDatePicker").datepicker({ format: 'dd/mm/yyyy', date: new Date(1900, 01, 01), autoclose: true, todayBtn: 'linked' });

    });



 


</script>

Layout

<head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>@ViewData["Title"] - MetaWeather</title><link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" /><link rel="stylesheet" href="~/css/site.css" /><link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css" /><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css" /><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css" /></head><script src="~/lib/jquery/dist/jquery.min.js"></script><script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script><script src="~/js/site.js" asp-append-version="true"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script><script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script><script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/js/toastr.min.js"></script><script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script><script src="https://kit.fontawesome.com/e19c476714.js"></script>


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>