Как мне добавить тег script, например
<script src="somejsfile"></script>
или
<script type="text/javascript>some javascript</script>
в верхний тег страницы с частичного просмотра?
Обновление: ответьте на старый вопрос Это касается ASP.NET MVC. Мы можем использовать RenderSection. Здесь образец для MVC 3 с использованием механизма просмотра Razor:
макет или главная страница:
<html>
<head>
<script ...></script>
<link .../>
@RenderSection("head")
</head>
<body>
...
@RenderBody()
...
</body>
</html>
Просмотр, например. Главная:
@section head{
<!-- Here is what you can inject the header -->
<script ...></script>
@MyClass.GenerateMoreScript()
}
<!-- Here is your home html where the @RenderBody() located in the layout. -->