I am trying to send my model back to the controller with 2 values retrieved from a map control. I figured the best solution would be to put these values in a hidden input 'Html.hiddenfor()' so the controller receives the values in the model.
This is my JavaScript
endDragDetails = function (e) {
alert("Event Info - start drag \n" + "Start Latitude/Longitude: " + e.entity.getLocation());
var locationx = e.entity.getLocation();
alert(locationx.latitude);
document.getElementById("longitude").value = parseFloat(locationx.longitude);
}
The alertboxes show me there is a floating point value in the locationx var. I've tried passing it with the parseFloat() function In case the floating point number is actually a string. The id of longitude is indeed "longitude", I checked that in the html source.
this is my cshtml part
@Html.HiddenFor(m => m.longitude);
All I'm getting back is a 0,0. Am I missing something in this solution?
UPDATE If I change the hiddenfor with @Html.TextBoxFor(m => m.longitude) it displays the longitude in my textbox after executing the javascript method. However it does not send it to the controller, the value remains 0,0. It does however send all my other values like for example first name string, ... to the controller.