[转]How to add a script in a partial view in MVC4?
2021-06-16 23:04
标签:locate and ati tty oat note 问题 asp.net message 本文转自:https://stackoverflow.com/questions/14114084/how-to-add-a-script-in-a-partial-view-in-mvc4 问题: This is the code which I have in my partial view Please note at the bottom of my code, I‘ve got a How can I tell to MVC4 in a partial razor view that I want to add that library? 参考答案: This worked for me allowing me to colocate JavaScript and HTML for partial view in same file for ease of readability In View which uses Partial View called "_MyPartialView.cshtml" In Partial View file Another way to use this is to pass the [转]How to add a script in a partial view in MVC4? 标签:locate and ati tty oat note 问题 asp.net message 原文地址:http://www.cnblogs.com/freeliver54/p/7268994.html@model Contoso.MvcApplication.Models.Exercises.AbsoluteArithmetic
@using(Html.BeginForm())
{
@section
, and I realized that it‘s not running if I set a breakpoint there. If I move that line in the _Layout.cshtml it works well, but that‘s not the idea.@model SomeType
@{
var region = ViewData["Region"] as string;
}
@if (region == "HTMLSection")
{
}
@if (region == "ScriptSection")
{
script type="text/javascript">
script">
}
另外关于 aspnetcore下的 How to use ViewDataDictionary with Html.Partial in asp.net core?
ViewData
of the current view into the constructor. That way the new ViewDataDictionary
gets extended with the items you put in using the collection initializer.@Html.Partial("MyPartial", new ViewDataDictionary(ViewData) { { "BookId", Model.Id } })
文章标题:[转]How to add a script in a partial view in MVC4?
文章链接:http://soscw.com/index.php/essay/94778.html