I'm using MVC and AJax.BeginForm to do some ajax updating of my page. The BeginForm code looks something like:
using (Ajax.BeginForm("HandleCrop", "Card",
new
{
accept = true,
id = Model.ImageUpload.ID,
file = Model.ImageUpload.File,
imageCropX = Model.CropInfo.X,
imageCropY = Model.CropInfo.Y,
imageCropWidth = Model.CropInfo.Width,
imageCropHeight = Model.CropInfo.Height
},
new AjaxOptions
{
HttpMethod = "POST",
OnComplete = "ConfirmCompleted",
OnSuccess = "ReloadUpload",
OnFailure = "Failure"
}, null))
The Model.CropInfo is being put in as hidden fields like so:
<%=Html.HiddenFor(m => m.CropInfo.X) %>
<%=Html.HiddenFor(m => m.CropInfo.Y) %>
<%=Html.HiddenFor(m => m.CropInfo.Width) %>
<%=Html.HiddenFor(m => m.CropInfo.Height) %>
However, these values are being dynamically modified by some client side javascript, and these values need to be posted through the Ajax call back to the server. The above code will obviously not work as the imageCrop.. parameters in the Ajax form are being filled when the page is rendered (therefore being all 0).
My question is: what is the correct way to approach this situation?