我有一些方法
public ActionResult ExportToCSV(CellSeparators cellSeparator)
{
//
}
public enum CellSeparators
{
Semicolon,
Comma
}
我们如何在html中正确引用该方法?
@Html.ActionLink("Exportar al CSV", "ExportToCSV", new { ?? })
谢谢!
答案 0 :(得分:2)
@ Html.ActionLink(“Exportar al CSV”,“ExportToCSV”,新{ cellSeparator =(int)CellSeparators.Semicolon })
和
public ActionResult ExportToCSV(int cellSeparator)
{
CellSeparator separator = (CellSeparator)cellSeparator;
}
不优雅,但很有用
答案 1 :(得分:2)
进入View.cshtml:
@Html.ActionLink("Exportar al CSV", "ExportToCSV", new { cellSeparator=CellSeparators.Semicolon })
进入你的控制器:
public ActionResult ExportToCSV(CellSeparators? cellSeparator)
{
if(cellSeparator.HasValue)
{
CellSeparator separator = cellSeparator.Value;
}
/* ... */
}