我遇到了一些麻煩。未在ASP.NET MVC中調用java腳本
我在我的MVC應用程序中以下幾種觀點:
@model Radio_Management_Interface.Models.Blocks.blocks_create
@{
ViewBag.Title = "Create Block";
Layout = "~/Views/Shared/_Layout_main.cshtml";
}
<script>
function getSelectedValue(sel) {
window.alert("You change the combo box");
}
</script>
<div class="contenttitle">
<h2 class="form"><span>Create A New Block</span></h2>
</div><!--contenttitle-->
@using (Html.BeginForm("Create", "Blocks", FormMethod.Post, new { @class = "stdform" }))
{
@Html.AntiForgeryToken()
<hr />
@Html.ValidationSummary(true)
<p>
<label>Select Network</label>
<span class="field">
<select name="select" onclick="getSelectedValue">
@foreach (var item in Model.networks)
{
<option value="@item.networkID">@Html.DisplayFor(modelItem => item.name)</option>
}
</select>
</span>
@Html.ValidationMessageFor(model => model.block.start)
<small class="desc">Name of the customer.</small>
</p>
關注的特定部分是:
<select name="select" onclick="getSelectedValue">
爲什麼會這樣的事件不能被稱爲?當我在網站上的select元素中更改選項時,我的JavaScript文件無法運行。爲什麼會這樣呢?