I am using JavaScript to dynamically add rows to a table using ASP .NET MVC's Razor syntax.Assigning a text-box to a variable works fine However, when I want to assign a drop-down list , it throw's an error - "Unexpected Illegal Token".
var expH = '@Html.DropDownList("TransDebit[{id}].Expenditure_Head",new SelectList(ViewBag.ExpCodes,"Expenditure_Code","Expenditure_Code"))';
Converts to (As seen from chrome's console) :
var expH = '<select id="TransDebit__id___Expenditure_Head" name="TransDebit[{id}].Expenditure_Head"><option value="313">313</option>
<option value="414">414</option>
</select>';
Which is exactly what I want but why does it throw an error ? I can't see anything wrong with it.
Please Help.
Thanks.
EDIT 1: SCREENSHOT
