0

私は誰かが助けるのに十分な情報を与えたことを望んでいます。(私は、関連性がないと感じたコードの一部を切り取りました)

私はjqueryテンプレートを持っています。その中にはIDをActionResultに返すリンクがあります。私の質問は、ActionResultが2つのパラメーターを受け取るように、リンクに別のパラメーターを追加するための構文は何ですか。

<script id="searchTemplate" type="text/x-jquery-tmpl">
  <a href="/Search/Details/${JournalId} WHAT GOES HERE?    ">
</script>

 public ActionResult Details(int id, string otherParameter)
    {
      var item = ctx.Journals.Find(id);
      return View("Details", item);
    }
4

2 に答える 2

1
<script id="searchTemplate" type="text/x-jquery-tmpl">
  <a href="/Search/Details/${JournalId}?otherParameter=value">
</script>
于 2011-05-06T13:04:58.650 に答える
0

はい、それは機能しますが、MS MVCの「ベストプラクティス」の方法は、Global.asaxに新しいルートを作成することです。

public static void RegisterRoutes(RouteCollection routes)
{
// callable like this: <a href="/Search/Details/${JournalId}/value"> 
routes.MapRoute(
            "MyNewRouteName",
            "MyController/SomeCoolAction/{id}/{otherParameter}",
            new { controller = "MyController", action = "SomeCoolAction"}
            );

....
}
于 2012-06-13T19:37:07.837 に答える