を_ViewStart.cshtmlHTMLはレンダリング正しくないとNO Viewbag.TitleはAjax.ActionLinks
@{
Layout = Request.IsAjaxRequest() ? null : "~/Views/Shared/_Layout.cshtml";
}
_Layout.cshtmlを用いて設定されていない
...
</head>
<body>
<div id="NavigationPanel">
@{ AjaxOptions options = new AjaxOptions
{
InsertionMode = InsertionMode.Replace,
UpdateTargetId = "ContentPanel",
OnBegin = "OnBeginAnimateContentPanel",
OnComplete = "OnCompleteAnimateContentPanel",
};}
<div>
<p>@Ajax.ActionLink("Users", "Index", "User", options)</p>
<p>@Ajax.ActionLink("Groups", "Index", "Group", options)</p>
<p>@Ajax.ActionLink("Permissions", "Index", "Permission", options)</p>
</div>
</div>
<div id="ContentPanel">
@RenderBody()
</div>
</body>
</html>
Global.Asax.cs
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Main", action = "Index", id = UrlParameter.Optional }
);
}
MainController.Indexアクション:ユーザー/グループ/パーミッション・コントローラー用
public ActionResult Index()
{
return View();
}
メインビューIndex.cshtml
@{
ViewBag.Title = "Test-Index";
}
this is the Index View of the MainController
インデックスビュー+アクションは、メインコントローラのインデックスのようなものです。タイトルは、ViewBagといくつかの小さなテストテキストに設定されています。
ここで間違っていることが1つあります。
Ajax.ActionLInksのいずれかをクリックすると、Viewが#ContentPanelで正しくレンダリングされますが、各ビュー(ユーザー/グループ/アクセス許可)のタイトルは表示されません。ただし、htmlソースコードをチェックすると、
ContentPanelのコンテンツは、インデックスビューのコンテンツですか?
これはなぜですか、どのようにして各Ajax.ActionLinkのビューのタイトルを設定できますか?
<body>
<div id="NavigationPanel">
<p><a data-ajax="true" data-ajax-begin="OnBeginAnimateContentPanel" data-ajax-complete="OnCompleteAnimateContentPanel" data-ajax-mode="replace" data-ajax-update="#ContentPanel" href="/User">Users</a></p>
<p><a data-ajax="true" data-ajax-begin="OnBeginAnimateContentPanel" data-ajax-complete="OnCompleteAnimateContentPanel" data-ajax-mode="replace" data-ajax-update="#ContentPanel" href="/Group">Groups</a></p>
<p><a data-ajax="true" data-ajax-begin="OnBeginAnimateContentPanel" data-ajax-complete="OnCompleteAnimateContentPanel" data-ajax-mode="replace" data-ajax-update="#ContentPanel" href="/Permission">Permissions</a></p>
</div>
<div id="ContentPanel">
this is the text within the Index View of the MainController
</div>
</body>
これは答えの50%です。なぜAjax.ActionLinkをクリックしたときに私のセットタイトルが表示されないのですか?どうすれば修正できますか? – Pascal
私は答えを更新しました...私はそれが助けてくれることを願っています。 –
私はあなたの答えをこの別の質問とは別に解決策としてマークします。おそらく答えがわかります:)私のMainController Indexアクションは実際には無価値です。その出発点... _Layout.cshtmlファイルで直接起動することはできませんか? – Pascal