title: asp.net mvc - how can you loop through model data in javascript
body: <p>I am tring to add data to a listbox in javascript, however the string building syntax has me stumped:</p>
  
  <p><code>var yourobject = '&lt;%=Model.Inserts['+ i + ']%&gt;';</code> </p>
  
  <p>causes an error: "Too many characters in character literal" </p>
  
  <p><strong>All of the code:</strong></p>
  
  <pre><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 &lt; '&lt;%=Model.Inserts.Count() %&gt;'; i++) {
                              var yourobject = '&lt;%=Model.Inserts['+ i + ']%&gt;';
                              mlb.add(yourobject, i);
                          }
  </code></pre>