当我推迟活动时,我希望将活动开始日期更改为延期日期?表格应返回更新活动开始日期和活动结束日期
public ActionResult Postpone(int ID)
{
var events = db.Events.Find(ID);
return PartialView(events);
}
//
// POST: /Events/Postpone/5
[HttpPost]
public ActionResult Postpone(FormCollection Collection)
{
var ID = Collection["Event_ID"];
int intID = int.Parse(ID);
var events = db.Events.Find(intID);
// If OK to Postpone , set status to P
events.Event_Status = "P";
if (TryUpdateModel(events))
{
//LIke to have option to change Event on the Form
db.SaveChanges();
string ConfirmMessage = "Event Successfully Postponed";
return RedirectToAction("Confirm", "Admin", new { ConfirmMessage = ConfirmMessage });
}
else
{
return PartialView(events);
}
}
这是我的推迟视图
@model MvcEvents.Models.Event
<h3>Are you sure you want to Postpone this?</h3>
@using (Ajax.BeginForm("Postpone", "Admin", new AjaxOptions { UpdateTargetId = "my-modal- dialog", OnBegin = "Dialog.Updating()", OnSuccess = "Dialog.Update()" }))
{
<fieldset>
<legend>Event</legend>
@Html.HiddenFor( model => model.Event_ID)
<div class="display-label">Event Location</div>
<div class="display-field">@Html.DisplayFor(model => model.Section.City)</div>
<div class="display-label">Event Start Date</div>
<div class="display-field"> @Html.DisplayFor(model => model.Event_Start) </div>
<div class="display-label">Event End Date</div>
<div class="display-field">@Html.DisplayFor(model => model.Event_End)</div>
<div class="display-label">Event Description</div>
<div class="display-field">@Html.DisplayFor(model => model.Event_Description)
</div>
</fieldset>
<p>
<input type="submit" value="Postpone" class="demo-button ui-state-default ui-corner-all" />
</p>
}
答案 0 :(得分:0)
我认为你想要的是@Html.EditorFor
或@Html.TextBoxFor
而不是@Html.DisplayFor