Asp.net mvc 我可以在同一个cshtml页面中插入html代码和Razor代码吗

Asp.net mvc 我可以在同一个cshtml页面中插入html代码和Razor代码吗,asp.net-mvc,Asp.net Mvc,我可以在同一页中插入带有此html代码的html设计/代码吗 @model project_final.Models.Bike @{ ViewBag.Title = "Create"; } <h2>Create</h2> @using (Html.BeginForm()) { @Html.ValidationSummary(true) <fieldset> @<legend>Bike</legend> @&l

我可以在同一页中插入带有此html代码的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")
@model project\u final.Models.Bike
@{
ViewBag.Title=“创建”;
}
创造
@使用(Html.BeginForm()){
@Html.ValidationSummary(true)
@自行车
@
@LabelFor(model=>model.Id)
@EditorFor(model=>model.Id)
@Html.ValidationMessageFor(model=>model.Id)
@LabelFor(model=>model.Color)
@EditorFor(model=>model.Color)
@Html.ValidationMessageFor(model=>model.Color)

} @ActionLink(“返回列表”、“索引”) @节脚本{ @Scripts.Render(“~/bundles/jqueryval”)
是的,你可以

只需注意Razor引擎中需要@的代码,以及html标记不需要像Stephen Muecke提到的那样的@。 @Bike前面不需要@,因为它是html标记


@永远不要坚持“html设计/代码”是什么意思?你指的是什么代码。为什么在
@Bike
@
中有
@
符号?你试过了吗?答案是肯定的还是否定的?这可以很简单地通过尝试和观察发生了什么来解决。Razor只是html的一种标记语法。你肯定可以嵌入html。
@Html.LabelFor(model => model.Id, new { @class = "col-md-2 control-label" })