techman123
New Member
I am trying to make a calendar site which will highlight holidays on a jquery ui datepicker (used inline). I already have the holidays I want to select (also displayed in a listbox on the page) via the following ViewModel with a strongly typed view:\[code\]public class HolidaysViewModel{public IEnumerable<string> SelectedDates { get; set; }public IEnumerable<SelectListItem> Holidays { get; set; }}\[/code\]How do I set the css class to 'highlight' the datepicker based on the Holidays property?I am trying something like this in my view:\[code\]$(function () { $("#calendar").datepicker({ dateFormat: 'dd/mm/yy',beforeShowDay: function(date){ var dates = <% Model.Holidays.Select(s => s.Value).ToList(); %>; for (var i = 0; i < dates.length; i++) { if (dates.toString() == date.toString()) { return [true, 'highlight']; } } return [true, ''];} });\[/code\]However the page does not display at all now as it doesn't like the line where I reference the Model. I am new to ASP.Net and Javascript and do not really understand these \[code\]<% <%: <%= %>\[/code\] brackets, especially when used in a script. Could somebody please explain what I am doing wrong?