Reputation: 37642
I have some method
public ActionResult ExportToCSV(CellSeparators cellSeparator)
{
//
}
public enum CellSeparators
{
Semicolon,
Comma
}
How we can refer to that method correctly in html?
@Html.ActionLink("Exportar al CSV", "ExportToCSV", new { ?? })
Thank you!
Upvotes: 5
Views: 1810
Reputation: 325
Into your View.cshtml:
@Html.ActionLink("Exportar al CSV", "ExportToCSV", new { cellSeparator=CellSeparators.Semicolon })
Into your Controller:
public ActionResult ExportToCSV(CellSeparators? cellSeparator)
{
if(cellSeparator.HasValue)
{
CellSeparator separator = cellSeparator.Value;
}
/* ... */
}
Upvotes: 3
Reputation: 2921
@Html.ActionLink("Exportar al CSV", "ExportToCSV", new { cellSeparator=(int)CellSeparators.Semicolon })
And
public ActionResult ExportToCSV(int cellSeparator)
{
CellSeparator separator = (CellSeparator)cellSeparator;
}
Is not elegant, but is usefull
Upvotes: 2