【发布时间】:2014-01-20 11:42:29
【问题描述】:
以下代码有什么问题?它是由添加视图向导生成的。当我导航到控制器时,我收到以下错误:String was not recognised as a valid Boolean 并突出显示以下行:@using (Html.BeginForm())
这里是视图:
@model Radio_Management_Interface.DomainModel.Entities.Network
@{
ViewBag.Title = "Create";
Layout = "~/Views/Shared/_Layout_main.cshtml";
}
<h2>Create</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Network</h4>
<hr />
@Html.ValidationSummary(true)
<div class="form-group">
@Html.LabelFor(model => model.name, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.name)
@Html.ValidationMessageFor(model => model.name)
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.startCode, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.startCode)
@Html.ValidationMessageFor(model => model.startCode)
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.frequency, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.frequency)
@Html.ValidationMessageFor(model => model.frequency)
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</div>
</div>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}`
控制器:
//
// GET: /Networks/Details/5
public ActionResult Details(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Network network = db.Networks.Find(id);
if (network == null)
{
return HttpNotFound();
}
return View(network);
}
领域模型:
public class Network
{
public int networkID { get; set; }
public string name { get; set; }
public int startCode { get; set; }
public decimal frequency { get; set; }
public virtual List<Block> blocks { get; set; }
}
【问题讨论】:
-
这是我的整个视图文件。我将添加控制器。
标签: c# asp.net asp.net-mvc asp.net-mvc-3 razor