if (@ViewBag.Title == "Title")
{
@ViewBag.Title
<div class="btnNEW" hidden id="fqXLS">
<select id = "fqcXLS">
<option id ="fqcXLSa">A</option>
<option id ="fqcXLSb">B</option>
<option id ="fqcXLSc">C</option>
<option id ="fqcXLSd">D</option>
</select>
@Html.ActionLink("Export To Excel", "ExportToExcel", "EEC", new { option = ??? }, new { @class = "cancel" })
</div>
}
I was able to make it work just by doing new{option="A"} but this will only send "A"
How can I use the selected value?
The ActionLink is created when the page is first rendered. It is not updated when the user selects from the dropdownlist (it will have the same initial value). Therefore, you will need to update the anchor href value using javascript or jquery.
There are many ways to achieve this, below is an unobtrusive way:
1) Give the ActionLink an ID:
2) Add event listener for the onchange event of the dropdown list (this should be called once the document is ready/loaded):
This will update the anchor href attribute when the select list is changed.