I'm trying to use templates.
I'm having trouble using using the Html.DisplayFor extension
I want the template to display all the data as read-only. I believe that HTML.DisplayFor can do this?
If this is so, I have a IEnumerable model being passed to the view:
@model IEnumerable<Tens.Models.Applicant>
@{
if (Model != null)
{
@Html.DisplayForModel("ApplicationOutcome")
}
}
and my Template:
@model IEnumerable<Tens.Models.Applicant>
@{
foreach(var item in Model)
{
@Html.TextBox("forenames",item.Forenames)
<br />
@Html.TextBox("surname",item.Surname)
<br />
<text>----------------------------------</text>
<br>
}
}
The above code works fine (2 records displayed) but it would mean me setting each fields readonly attribute to true (there are a load more fields - so tedious). What I want to do is use Html.DisplayFor to display this data as readonly, but I've tried numerous different ways and can't get it to work. Any help is appreciated.