开发者

asp.net mvc change date when Updating

When I Postpone Event I would like the also change the Event Start Date to the Postponed Date ? The Form Should return to Update The Event Start Date and Event End Date

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

this is my Postpone View

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

}


I think what you want is @Html.EditorFor or @Html.TextBoxFor instead of @Html.DisplayFor

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜