asp.net mvc - How to Insert an Inline Razor Expression into Javascript -


i have following script:

<script type="text/javascript"> function addrow() {      var count = $("#tbluploaddocs").prop('rows').length;     count += 1;      alert(count);     var html = '<tr>';     html += '<td><input type="file" name="files" id="file' + count + '" /></td>';     html += '<td>bu dilden</td>';      html += '<tr>';     alert(html);  } </script> 

i trying insert following line script, not achieve desired result:

<td>@html.dropdownlist("ddlfromlanguage1", viewbag.languages selectlist)</td>   

i tried both , @: not make work. looking forward hearing solution.

thanks in advance

use <text> pseudo-element, described here, force razor compiler content mode:

<script type="text/javascript"> function addrow() {   <text>     var count = $("#tbluploaddocs").prop('rows').length;     count += 1;      alert(count);     var html = '<tr>';     html += '<td><input type="file" name="files" id="file' + count + '" /></td>';     html += '<td>bu dilden</td>';      html += '<tr>';     alert(html);    </text> } </script> 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -