I'm obviously doing something daft here....
I have a view which displays some information (purely for display there's no data collection going on) with a continue button which when clicked should post the model being displayed back to the controller but the model is virtually always empty. An example being:
<p>Analysis Code: @Html.DisplayTextFor(m=> m.SFCode)</p>
Which passes a null value back to the controller (although it does display correctly on screen) but if I use:
<p>Analysis Code: @Html.TextBoxFor(m=> m.SFCode)</p>
Then the value is passed back to my controller but it displays in a textbox on the view which I don't want.
So basically I just want to display some 'stuff' and pass this 'stuff' back to the controller but I can't find a helper method that displays as I want and pass it in.
Could someone show my the light please?
Thanks, C
@using(Html.BeginForm()) // Creates <form>
{
<p>Analysis Code: @Html.DisplayTextFor(m=> m.SFCode)</p>
@Html.HiddenFor(m=>m.SFCode)
}
Add this into your form, it should work.
In order to POST your data back to the Controller
, you need it to be inside an input field right? In this case a hidden input field fits your need.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.