I am using @(new JavaScriptSerializer().Serialize(Model.DateSlotModel))) in my view and it causing a javascript error because it produces the following when in the script block:
var initialData = [{"DateID":"1","DateValue":"4/1/2011"}]);
What do I need to do to get the output to be formated as follows?
[{"DateID":"1","DateValue":"4/1/2011"}]
Controller Code:
jobmodel.DateSlotModel = from d in eventRepository.GetEventDates(eventid)
select new ScheduleDateSlotViewModel
{
DateID = d.DateID.ToString(),
DateValue = d.DateValue.ToShortDateString()
};
Thanks
Have you tried:
var InitialData = @Html.Raw(new JavaScriptSerializer().Serialize(Model.DateSlotModel)))
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