I have an action which looks like this:
public ActionResult NewPicture(int id)
{
var response = service.Get(id);
if (!response.Succeed)
return Error(response.MainError.ErrorType);
return ManagementView("/Gallery/EditPicture.cshtml", new PictureSaveViewModel() { Id = 0, GalleryId = id });
}
In the PictureSaveViewModel the GalleryId refers to parent gallery and the Id is the picture's Id. Because it's NewPicture action, The Id is set to 0 and the GalleryId set to the id parameter.
In the View, I have a form that contains multiple inputs for PictureSaveViewModel.
@Html.HiddenFor(model => model.Id)
@Html.HiddenFor(model => model.GalleryId)
Here are two hidden inputs for Id and GalleryId for the specified model.I expect that the hidden filed Id's value to be 0 and GalleryId's value to be the id of the parameter. But when I call the action like this /Gallery/NewPicture/82, both hidden fields value is 82
<input data-val="true" data-val-number="The field Id must be a number." data-val-required="The Id field is required." id="Id" name="Id" type="hidden" value="82">
<input data-val="true" data-val-number="The field GalleryId must be a number." data-val-required="The GalleryId field is required." id="GalleryId" name="GalleryId" type="hidden" value="82">
I don't know this is happening. I event tried to @Html.Hidden("Id" ,@Model.Id), but still same result.
Other input fiels like title, description, .... are working fine.