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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -