c# - Fill @Html.Hidden with div value -
let's have div this:
<div id ="carmodel"></div> this div gets populated using javascript 5 seconds after pageload, this:
<div id ="carmodel">audi a4</div> now need send text inside "carmodel" div controller when form submitted.
@using (html.beginform("method", "controller")) { @html.textbox("textbox1", "") @html.textbox("textbox2", "") <input type="submit" value="subtmit"/> } i thought using hidden field , posting together, don't know how populate hidden field text in "carmodel" div:
@html.hidden("carmodelhiden", ""); it seems if need use jquery retrieve text this:
var value = $("#carmodel").text(); but how send controller?
i thought using .ajax post not sure how handle value in controller once it's there, since ajax method in controller separate form gets posted.
anybody have advice?
you need set value of hidden input:
$('#carmodelhidden').val(...);
Comments
Post a Comment