I am tring to add data to a listbox in javascript, however the string building syntax has me stumped:
var yourobject = '<%=Model.Inserts['+ i + ']%>';
causes an error: “Too many characters in character literal”
All of the code:
var mlb = cm.createListBox('mylistbox', {
title: 'My list box',
onselect: function(v) {
tinyMCE.activeEditor.windowManager.alert('Value selected:' + v);
}
});
for (var i = 0; i < '<%=Model.Inserts.Count() %>'; i++) {
var yourobject = '<%=Model.Inserts['+ i + ']%>';
mlb.add(yourobject, i);
}
You can’t mix code that runs on the server (the transliteration of the
<% %>block) with that the runs on the client (the for loop) in that way. Do the iteration in C# rather than in javascript and create a javascript object in a string that you can simply assign.