0

is it possible to pass the value of a form element somewhere on the page, to an actionlink as a parameter? eg.

@Html.DropDownList("MyList")

@Html.ActionLink("FooText", "FooMethod", "FooController", dropdownvaluehere)

where in the FooController class

public ActionResult FooMethod(int retrieveddropdownvalue)
{
    //do something with retrieved value
}
2
  • Since the value is selected on the client, you need to construct the link using javascript/jquery Commented Oct 13, 2014 at 2:35
  • 1
    why not use a form to submit the information to the controller? Commented Oct 13, 2014 at 2:35

1 Answer 1

1

Just use Javascript/Jquery instead:

<a onclick = "myfunction()"> FooText </a>

in your script:

function myfunction()
{
    window.location = '@URL.Action("FooMethod", "FooController")?parameter=' + (get selected value from dropdown);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.