asp.net mvc更改日期何时更新



当我推迟事件时,我也想将事件开始日期更改为推迟日期?表单应该返回到更新事件开始日期和事件结束日期

    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>
}

我认为您想要的是@Html.EditorFor@Html.TextBoxFor而不是@Html.DisplayFor

最新更新