0

値を書き込む必要があるテキストボックスがあります。ActionLink を使用してコントローラーを呼び出す場合にコントローラーにこの値を渡す方法、これが私のコードです。

見る:

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

これがスクリプトです

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

ApplyCommandController でティッシュを送信する必要があります ありがとう

4

2 に答える 2

1

アクション リンクを使用する代わりに、標準のリンクを使用します。

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

次に、このスクリプトを使用できます。

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

次の href を割り当てます/Work/ApplyCommand/tisch

于 2012-08-14T13:09:42.320 に答える
0

これは正しいスクリプトでした:

 $("#l").attr("href", "@Url.Action("ApplyCommand", "Work")?tisch=" + tisch);
于 2012-08-14T13:50:34.953 に答える