User-474980206 posted
it is unclear what you are trying to do. while the "@" in razor is used to change to c# mode, in c# its the quote charter for reserved words
var @if = 0;
@{
foreach(var item in (List<AgendaModel>)ViewBag.ListaEventos)
{
<text>
@item.Id,
@item.Title,
@item.Start,
@item.End,
@item.AllDay,
@item.Color,
@item.TextColor;
</text>
}
}
will render the values with commas and trailing ;
if you where trying to initial a javascript array:
<script>
@foreach(var item in (List<AgendaModel>)ViewBag.ListaEventos)
{
<text>events.push({
id: '@item.Id',
title: '@item.Title',
start: '@item.Start',
end: '@item.End',
allDay: '@item.AllDay',
color: '@item.Color',
testColor: '@item.TextColor';
});</text>
}
}
</script>
but json serialize would be better
<script>
var events = @Html.Raw
(
JsonConvert.SerializeObject(ViewBad.ListaEvents, new JsonSerializerSettings
{
ContractResolver = new DefaultContractResolver
{
NamingStrategy = new CamelCaseNamingStrategy()
};
})
);
</script>
this code makes no sense:
'@ViewBag.Id' = id
if the value of id is 10 then it renders
10 = id