質問編集履歴
2
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -86,7 +86,7 @@
|
|
86
86
|
|
87
87
|
|
88
88
|
|
89
|
-
追記
|
89
|
+
追記-1
|
90
90
|
修正依頼を受けまして出力されたhtmlファイルを追記します。
|
91
91
|
(見やすいように改行・インデントは変更しています。)
|
92
92
|
```
|
@@ -120,4 +120,31 @@
|
|
120
120
|
|
121
121
|
</body>
|
122
122
|
</html>
|
123
|
-
```
|
123
|
+
```
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
追記-2
|
128
|
+
部分ビューは別のページにも配置されるので、
|
129
|
+
@Html.Partal("_TopixView")の次の行に@section scriptsを書く案は、現実的ではないですね。
|
130
|
+
いちおう試してみたのですが@section scriptsの分割して書くと
|
131
|
+
「HttpException」が吐かれるので、一カ所にまとめないと駄目でした。
|
132
|
+
セクション名を変えれば大丈夫でしたが。
|
133
|
+
|
134
|
+
外部ファイルにする案は、
|
135
|
+
topix.js
|
136
|
+
```JavaScript
|
137
|
+
document.getElementById("topixTitle").style.color = "red";
|
138
|
+
```
|
139
|
+
|
140
|
+
_TopixView.cshtml
|
141
|
+
```
|
142
|
+
<h2 id="topixTitle">トピックス</h2>
|
143
|
+
|
144
|
+
<script type="text/javascript" src="~/Scripts/topix.js"></script>
|
145
|
+
```
|
146
|
+
上記のようにすると反映されるようになりました。
|
147
|
+
|
148
|
+
ただ、sk_3122様が書かれているのですが、投稿したコードのように単純なものではなく
|
149
|
+
実際のコードはAjaxでJSONデータ受け取ってDOMでゴニャゴニャするつもりなので、
|
150
|
+
どうなるかを試してみたいと思います。
|
1
コードの追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -82,4 +82,42 @@
|
|
82
82
|
Visual Studio Professional 2017
|
83
83
|
ASP.NET MVC 5
|
84
84
|
Bootstrap 3.3.7
|
85
|
-
jQuery 3.2.1
|
85
|
+
jQuery 3.2.1
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
追記
|
90
|
+
修正依頼を受けまして出力されたhtmlファイルを追記します。
|
91
|
+
(見やすいように改行・インデントは変更しています。)
|
92
|
+
```
|
93
|
+
<!DOCTYPE html>
|
94
|
+
<html>
|
95
|
+
|
96
|
+
<head>
|
97
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
98
|
+
<meta charset="utf-8" />
|
99
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
100
|
+
<title>Home Page - マイ ASP.NET アプリケーション</title>
|
101
|
+
<link href="/Content/bootstrap.css" rel="stylesheet" />
|
102
|
+
<link href="/Content/site.css" rel="stylesheet" />
|
103
|
+
<script src="/Scripts/modernizr-2.6.2.js"></script>
|
104
|
+
</head>
|
105
|
+
|
106
|
+
<body>
|
107
|
+
<div class="container body-content">
|
108
|
+
<h2 id="title">Home Index</h2>
|
109
|
+
<div>
|
110
|
+
<h2 id="topixTitle">トピックス</h2>
|
111
|
+
</div>
|
112
|
+
</div>
|
113
|
+
|
114
|
+
<script src="/Scripts/jquery-1.10.2.js"></script>
|
115
|
+
<script src="/Scripts/bootstrap.js"></script>
|
116
|
+
<script src="/Scripts/respond.js"></script>
|
117
|
+
<script type="text/javascript">
|
118
|
+
document.getElementById("title").style.color = "blue";
|
119
|
+
</script>
|
120
|
+
|
121
|
+
</body>
|
122
|
+
</html>
|
123
|
+
```
|