mvcアプリケーション用に_Layout.cshtmlを定義しました。これを以下に示します。
@inherits System.Web.Mvc.WebViewPage
@using Webdiyer.WebControls.Mvc;
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
@RenderSection("HeaderContent", false)
</head>
<body>
@RenderBody()
</body>
</html>
SomePage.cshtmlページには、レイアウトを含め、部分的なレンダリング構造も含めました。これは、_MailForm.cshtmlをこのページにレンダリングするためです。
@{
View.Title = "page";
Layout = "~/Views/Shared/_Layout.cshtml";
}
@Html.Partial("_MailForm")
私の_MailForm.cshtmlファイルは次のようになります。
@inherits System.Web.Mvc.WebViewPage<CMS.Models.Mail.MailModel>
@section HeaderContent
{
<script src="@Url.Content("~/Scripts/mail.js")" type="text/javascript"></script>
}
<form>...</form>
_MailForm.cshtmlで宣言されたHeaderContentセクションは、_Layout.cshtmlからレンダリングされ、mail.jsスクリプトをロードすると想定しています。スクリプトは実際にはロードされていないため、フォームロジックが機能していません。そのHeaderContentセクションを_MailForm.cshtmlからSomePage.cshtmlに移動すると、mvcがスクリプトをロードするため、すべてが機能します。
しかし、_MailForm.cshtmlファイル内からそのスクリプトをロードする方法は?
よろしく