在Javascript代码中使用Html.dropdownList() [英] Using Html.dropdownList() in Javascript Code
本文介绍了在Javascript代码中使用Html.dropdownList()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想像这样将行动态添加到我的表中:
I want to add row to my table dynamicly like this :
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)');
但输出是:
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>');
我如何使用html.!!!在我的javascript中?!
how can I use html.!!! in my javascript ?!
推荐答案
非常感谢.对我有用的答案是:
Thanks a lot guys . The answer that work for me was :
newCell.innerHTML = '@Ajax.JavaScriptStringEncode(Html.DropDownList("AppVersionGroupId", string.Empty).ToHtmlString())'
如果有任何问题,请通知我.
If anything is wrong let me know .
这篇关于在Javascript代码中使用Html.dropdownList()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文