Jav*_*imi 1 javascript asp.net-mvc html-helper html.dropdownlistfor
我想动态地向我的表添加行,如下所示:
var tableRef = document.getElementById('tblData').getElementsByTagName('tbody')[0];
var newRow = tableRef.insertRow(tableRef.rows.length);
var newCell = newRow.insertCell(0);
newCell.appendChild(document.createElement('input'));
var newCell = newRow.insertCell(1);
newCell.appendChild('@Html.DropDownList("AppVersionGroupId", string.Empty)');
Run Code Online (Sandbox Code Playgroud)
但输出是:
newCell.appendChild('<select id="AppVersionGroupId" name="AppVersionGroupId"><option value=""></option>
<option value="46a08053-56e3-4320-aec3-7b521cca28ab">op1</option>
<option value="36ff6b7a-bdef-4506-b771-95cc42cd2667">op2</option>
<option value="e84fcfc5-8a46-47fd-8584-c00a5642f246">op3</option>
</select>');
Run Code Online (Sandbox Code Playgroud)
我怎么能用html.!!! 在我的JavaScript中?
非常感谢你们.对我有用的答案是:
newCell.innerHTML = '@Ajax.JavaScriptStringEncode(Html.DropDownList("AppVersionGroupId", string.Empty).ToHtmlString())'
Run Code Online (Sandbox Code Playgroud)
如果有任何问题,请告诉我.
| 归档时间: |
|
| 查看次数: |
3004 次 |
| 最近记录: |