From what I understand, you want to fill a property in your model through Jquery.
If this is the case, you can place a hidden input in the view representing your model, and change the value of the model through Jquery. If the element already exists (not an Hidden), just take the HTML element and change its value. MVC performs the Binding model to send the model to its controller through the elements name.
For example:
@model Meu.Model.FooModel
@using (Html.BeginForm())
{
@Html.HiddenFor(e => e.Atributo, new { id = "AtributoDoModel" })
<input type="submit" val="Enviar" />
}
<script>
$(document).ready(function(){
$("#AtributoDoModel").val("NovoValorDoMeuAtributo");
});
</script>
The above code must change the Foomodel Attribute property to the "Novovalordomeuattribute" value, as scripted in Jquery.
Pass parameters directly to model? This is wrong.
– Tiago César Oliveira
Okay, I accept guidance.
– pnet
Do you want to put information into your model through Jquery to get it to the filled controller? That’s it?
– Vinícius