Javascript sequential processing format

I use @(new JavaScriptSerializer().Serialize(Model.DateSlotModel)))in my view and it causes a javascript error because in the script block it produces the following:

var initialData = [{"DateID":"1","DateValue":"4/1/2011"}]); 

What do I need to do to get the output file 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()
                         };

thank

+3
source share
1 answer

You tried:

 var InitialData = @Html.Raw(new JavaScriptSerializer().Serialize(Model.DateSlotModel)))
+4
source

Source: https://habr.com/ru/post/1795068/


All Articles