私はMVC3アプリケーションに取り組んでいます。私のビューには、コントローラーに移動したいロジックがあります。モデルの特定の側面に応じて、ActionLink を動的に表示します。異なるのは、Html.ActionLink の linkText パラメーターと actionName パラメーターだけです。linkText と actionName の文字列を含む JsonResult を返すメソッドをコントローラーに追加しました。
[AcceptVerbs(HttpVerbs.Get)]
public JsonResult GetActionButton(int id)
{
string action = null;
string text = null;
// Snipped stuff that sets action and text
return Json(new
{
buttonAction = action,
buttonText = text
});
}
結果を使用してリンクを作成するには、このメソッドをどこで呼び出すことができますか?