【发布时间】:2020-01-18 10:12:40
【问题描述】:
if (@ViewBag.Title == "Title")
{
@ViewBag.Title
<div class="btnNEW" hidden id="fqXLS">
<select id = "fqcXLS">
<option id ="fqcXLSa">A</option>
<option id ="fqcXLSb">B</option>
<option id ="fqcXLSc">C</option>
<option id ="fqcXLSd">D</option>
</select>
@Html.ActionLink("Export To Excel", "ExportToExcel", "EEC", new { option = ??? }, new { @class = "cancel" })
</div>
}
我能够通过执行 new{option="A"} 使其工作,但这只会发送“A”
如何使用选定的值?
【问题讨论】:
-
看起来您的
<option>标签都没有填充value属性see the MDN documentation。这也取决于你想如何使用选定的值?如果在 Javascript 中,请查看此答案 stackoverflow.com/a/1085810/3338349 -
那么,在用值设置我的选项之后,如何从 actionlink 传递它?选项 = document.getElementById("fqxXLS").value ?或类似的东西?
-
我也试过@Html.ActionLink("Export To Excel", "ExportToExcel", "EEC", new { option= "getCategory();" }, new { @class= " cancel" }) 创建一个函数来返回 ID 的值,然后在 actionlink 中调用该函数。好像不行
标签: c# parameters html.actionlink