0

I have a textbox where i must to write a value, how to pass this value in my controller if I call my controller using ActionLink, this is my code:

view:

@Html.TextBox("tisch", "", new { @class = "teschChange"})
@Html.ActionLink("Apply Command", "ApplyCommand", "Work")

and this is te script

<script type="text/javascript">
    $(function test() {
        $(".teschChange").change(function () {
            var tisch = $(this).attr('value');
        });
    });
</script>

I must to send tisch in ApplyCommandController Thanks

2 Answers 2

1

Instead of using an action link, use a standard link:

<a id="l" href="@Url.Action("ApplyCommand", "Work")">Apply Command</a>

Then, you can use this script:

<script type="text/javascript">
    $(function test() {
        $(".teschChange").change(function () {
            var tisch = $(this).attr('value');
            $("#l").attr("href", "@Url.Action("ApplyCommand", "Work")/" + tisch);
        });
    });
</script>

Which will assign a href of: /Work/ApplyCommand/tisch.

Sign up to request clarification or add additional context in comments.

1 Comment

Object[object Object] has no method 'href'
0

this was the correct script:

 $("#l").attr("href", "@Url.Action("ApplyCommand", "Work")?tisch=" + tisch);

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.