I have a dropdown list and a link next to the dropdown list. When the button is clicked, I want an action to be invoked on the controller so I can download my file by the SelectedFileId selected in the dropdown list. The problem is, when I view the link url in the console, it is only
http://localhost/Download/DownloadFileById
Which isn't including my parameter. I assume that is because Model.SelectedFileId is null when the html is generated. Is there a way I can get that URL to be dynamic and change whenever I change the dropdown?
My code:
@Html.DropDownListFor(x => x.SelectedFileId, Model.FileIds)
@Html.ActionLink("Download File",
"DownloadFileById",
"Download",
new { fileId = Model.SelectedFileId })