As the title states, I want to define a section in a partial view.
My code that I've tested with are as follows:
Controller:
public ActionResult Test()
{
return View();
}
public ActionResult PartialTest()
{
return PartialView("_PartialTest");
}
Test.cshtml:
@{
ViewBag.Title = "Test";
}
<h2>Test</h2>
@Html.Action("PartialTest")
_PartialTest.cshtml:
<p>partial Test</p>
@section scripts {
<script type="text/javascript">
$(document).ready(function() {
alert("Test");
});
</script>
}
Placing the section scripts
in the Test.cshtml works fine so the problem isn't in the layout.
Anyone know how to do this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…