在ASP.net MVC视图中使用脚本和样式标签?

时间:2015-08-23 15:37:06

标签: javascript css asp.net-mvc

在MVC视图中使用<script></script><style></style>标记是一种好习惯吗?例如,请在随附的简单视图示例中考虑以下代码段。              function myFunction(){             //在这做点什么             返回false;         }                   .myCssClass {color:red}     

@model JavaScript_CSS_Test.Models.Employee

@{
    ViewBag.Title = "Create";
}

<h2>Create</h2>

@using (Html.BeginForm()) {
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Employee</legend>
        <div class="editor-label">
            @Html.LabelFor(model => model.Name)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Name)
            @Html.ValidationMessageFor(model => model.Name)
        </div>

        <p>
            <input type="submit" id="btnSubmit" value="Create" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>
<script type="text/javascript">
    function myFunction() {
        //do something here
        return false;
    }
</script>
<style type="text/css">
    .myCssClass{ color:red }
</style>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")

}

0 个答案:

没有答案