我有一些方法
public ActionResult ExportToCSV(CellSeparators cellSeparator)
{
//
}
public enum CellSeparators
{
Semicolon,
Comma
}
我们应该如何在HTML中正确地引用那个方法?
@Html.ActionLink("Exportar al CSV", "ExportToCSV", new { ?? })
谢谢你!
我有一些方法
public ActionResult ExportToCSV(CellSeparators cellSeparator)
{
//
}
public enum CellSeparators
{
Semicolon,
Comma
}
@Html.ActionLink("Exportar al CSV", "ExportToCSV", new { ?? })
@Html.ActionLink("Exportar al CSV", "ExportToCSV", new { cellSeparator=CellSeparators.Semicolon })
在你的控制器中:
public ActionResult ExportToCSV(CellSeparators? cellSeparator)
{
if(cellSeparator.HasValue)
{
CellSeparator separator = cellSeparator.Value;
}
/* ... */
}
@Html.ActionLink("导出CSV", "ExportToCSV", new { cellSeparator=(int)CellSeparators.Semicolon })
以及
public ActionResult ExportToCSV(int cellSeparator)
{
CellSeparator separator = (CellSeparator)cellSeparator;
}
虽然不够优雅,但却非常有用