我有一些方法
public ActionResult ExportToCSV(CellSeparators cellSeparator)
{
//
}
public enum CellSeparators
{
Semicolon,
Comma
}
我们如何在 html 中正确引用该方法?
@Html.ActionLink("Exportar al CSV", "ExportToCSV", new { ?? })
谢谢!
最佳答案
进入您的 View.cshtml:
@Html.ActionLink("Exportar al CSV", "ExportToCSV", new { cellSeparator=CellSeparators.Semicolon })
进入你的 Controller :
public ActionResult ExportToCSV(CellSeparators? cellSeparator)
{
if(cellSeparator.HasValue)
{
CellSeparator separator = cellSeparator.Value;
}
/* ... */
}
关于c# - 如何将枚举值传递给@Html.ActionLink,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12254669/