Here is the code snippet in my aspx.cs file:
public partial class BarChart
{
public class LabelsDetail
{
public string LabelId { get;set; }
public string LabelDesc { get; set; }
}
public List<LabelsDetail> LabelsDetails { get; set; }
public void InsertDataToLabelsDetails()
{
// Data is populated into "LabelsDetails" from a source
}
}
Along with the following JavaScript code on the ASPX page:
function setupBarChart(JQObjectContainer, JsonData) {
var hashTableSize = <%=this.LabelsDetails.Count%>;
var hashtable = {};
if (hashTableSize != 'undefined' && hashTableSize > 0)
{
for (var item in <%=this.LabelsDetails%>)
{
hashtable[item.LabelId] = item.LabelDesc;
}
}
}
I am trying to iterate over a server-side list in the client-side. How can I achieve this?
Currently, when attempting to loop through the server-side list (this.LabelsDetails
), I encounter an error
Uncaught SyntaxError: Unterminated template literal
.
Any guidance or assistance would be greatly appreciated.