3

意見:

@using (@Html.BeginForm("Show", "test", FormMethod.Post))
{

    <fieldset>

        <table >
            <tr>
                <td>
                    @Html.LabelFor(model=> model.Show)
                </td>

                <td>
                 @Html.TextBox("txtvalue", null)

                </td>
            </tr>


        </table>


             <input type="button" value="Show" onclick = "@("location.href='"+ @Url.Action("Show", "test")+"'" )" />

           <input type="button" value="Go" onclick ="@("location.href='"+ @Url.Action("Go", "test")+"'" )"/>




    </fieldset>
}

コントローラの 2 つのアクション メソッド、

public ActionResult Show(string txtvalue)
{
    ...
} 

public ActionResult Go(string txtvalue)
{
    ...
} 

どのボタンがクリックされたかに基づいて、対応するアクションメソッドに移動し、テキストボックスの値を渡す必要があります。

誰でも私にそれを行う方法を提案できますか。頭をぐるぐるまわしたが、わからなかった。

4

3 に答える 3

0

これを試して

<input type="button" value="Show" onclick="location.href='<%: Url.Action("Show", "Controller") %>'" />

<input type="button" value="Go" onclick="location.href='<%: Url.Action("Go", "Controller") %>'" />
于 2013-10-09T13:01:49.723 に答える