【发布时间】:2015-08-26 12:46:07
【问题描述】:
我可以在同一页面中插入带有此 Razor CSHTML 代码的 html 设计/代码吗?
@model project_final.Models.Bike
@{
ViewBag.Title = "Create";
}
<h2>Create</h2>
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
@<legend>Bike</legend>
@<div class="editor-label">
@Html.LabelFor(model => model.Id)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Id)
@Html.ValidationMessageFor(model => model.Id)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Color)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Color)
@Html.ValidationMessageFor(model => model.Color)
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
【问题讨论】:
-
你是什么意思“html设计/代码”?你指的是什么代码。为什么
@<legend>Bike</legend>和@<div class="editor-label">中有@符号? -
你试过了吗?答案是肯定的还是否定的?只需尝试并观察会发生什么,就可以非常简单地解决这个问题。
-
Razor 只是 html 的标记语法。您绝对可以嵌入 HTML。
标签: asp.net-mvc