1

ajaxを使用してパラメーターを取得します。この時点では問題はありませんが、Controllerメソッドでリンクを指定してパラメーターIDを追加する方法があります。ビューにリンクを表示したいので、そのリンクをクリックすると、パラメーターのIDを使用して別のビューをルーティングしたい

これが私のコントローラーです:

public string corporate()
        {

            var management = "";
            var management_id=""; ? How can I add this paremeter to link to route another View with this parameter
            foreach (var query in db.corporate)
            {

                management =management + "<li><input type='checkbox'/><label>"+query.person_position+"</label></li>";
            }
            return (management);
        }

MVCに@Html.Actionlink()タグがあり、追加できないので、ajaxを使用してパラメーターIDを追加するにはどうすればよいですか?

4

2 に答える 2

1
[HttpGet]    
public ActionResult MyAction(string id){

}



<a href="/controlle/myaction/1234">Link</a>

getリクエストを実行するだけで、パラメータIDに名前を付け、この方法で値を渡すようにしてください。

于 2012-10-04T14:48:02.010 に答える
1

@ Url.Actionには、次のようないくつかのパラメーターを追加できます。

@Url.Action( "ActionName", "ControllerName", new { parameterId = Model.Id } )
于 2012-10-04T12:57:17.883 に答える