I’ve embeded the following server side code within <script> tag.
<% Dim dataTable As DataTable = cTab.getTabs(Session("UserID"))
If (dataTable.Rows.Count > 0) Then
For i As Int16 = 0 To dataTable.Rows.Count%>
{
contentEl: 'tab'+'<%dataTable.Rows(0)("TabID").ToString()%>',
title: '<%dataTable.Rows(0)("TabName").ToString()%>',
closable: false,
autoScroll: true
},
<% Next
End If %>
But it is not returning the desired results due to syntax problems. How can I write it correctly?
You’ve only given us a portion of the entire javascript, so we can’t analyze what the surrounding script looks like in order to look for syntax issues. The snippet you’ve given will just start with an opening curly brace, which is not valid just standing by itself. What’s preceeding it?
Besides that, if you want to output a string to the script, you need to do it using
Response.Writeor using the<%= %>shortcut. So for one, you need to do:(Notice the = signs).