W
W
wkololo_4ever2014-02-25 19:24:15
ASP.NET
wkololo_4ever, 2014-02-25 19:24:15

Why isn't the field value updated?

There is a Profile model, which I pass to the View and edit there

public class Profile
    {
        public int Id { get; set; }

        public int UserId { get; set; }
        public virtual User User { get; set; }

        public string FirstName { get; set; }
        public string LastName { get; set; }
        public int Age { get; set; }
        public DateTime LastUpdateDate { get; set; }
        public string Avatar { get; set; }
    }

Here is the form in the View
@using(Html.BeginForm("EditProfile","Profile"))
{ 
    @Html.LabelFor(m => m.Age)
    @Html.EditorFor(m => m.Age)
    @Html.LabelFor(m => m.Avatar)
    @Html.EditorFor(m => m.Avatar)
    @Html.LabelFor(m => m.FirstName)
    @Html.EditorFor(m => m.FirstName)
    @Html.LabelFor(m => m.LastName)
    @Html.EditorFor(m => m.LastName)    
    @Html.HiddenFor(m=>m.Id)
    @Html.HiddenFor(m => m.LastUpdateDate,new { value=DateTime.Now})
    @Html.HiddenFor(m => m.UserId)
    <input type="submit" value="Сохранить">
}

The LastUpdateDate field is not updating to "DateTime.Now" maybe I'm changing the field incorrectly?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question