我正在为 Event 数据模型创建一个编辑表单,其中输入元素填充有用于编辑的 Event 属性。在我完成填充字段并格式化页面后,我意识到我忘记了表单标签。添加它们后,我的 Razor 代码完全停止工作,所有输入元素都为空。我尝试禁用代码的各个部分,包括所有 javascript 和 css,除了删除表单标签之外,似乎没有任何东西可以重新填充字段。
这是代码:
@model Objects.Models.Event.Event
@using EventSignup.Extensions
@{
ViewBag.Title = "Edit";
}
<script src="@Url.Content("~/Scripts/jquery-ui-1.8.22.min.js")" type="text/javascript"></script>
<link href="@Url.Content("~/Content/themes/base/jquery.ui.all.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Javascript/jquery-ui-timepicker-addon.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Javascript/Edit.js")" type="text/javascript" ></script>
<h2>Edit</h2>
<div class="hero-unit">
<form action="" id="event_form" method="post">
<label for="name">Event Name:</label>
<input type="text" name="name" id="name" value="@Model.EventName" /><br />
<label for="tickets"># of Tickets:</label>
<input type="text" name="tickets" id="tickets" value="@Model.Tickets" /><br />
<label for="location">Location:</label>
<select name="location" id="location">
@foreach (var Element in ViewBag.Buildings as List<EventSignup.ViewModels.SelectElement>)
{
<option value="@Element.ID" @((Model.TicketsLocation.ID == @Element.ID) ? "selected='selected'" : "")>@Element.DisplayName</option>
}
</select><br />
<label for="dates">Dates/Times:</label>
@foreach (var EventInfo in Model.Dates)
{
<input type="text" class="date" name="dates" id="dates@(Model.Dates.IndexOf(EventInfo)+1)" value="@EventInfo.DateTime.ToDateTimePickerString()"/><br />
if (EventInfo != Model.Dates.Last())
{
<label></label>
}
}
<div id="date_inputs">
</div>
<label></label>
<span id="new_date" class="fauxlink" onclick="newDate()">New Date/Time</span><br /><br />
<input type="hidden" id="num_dates" value="@Model.Dates.Count" />
<input type="submit" id="submit" value="Submit" /><br />
</form>
</div>