I'm new to razor and display templates so please correct me where I'm wrong. I'm working with a string that contains HTML. If I try converting it directly to a HtmlString, my Ajax form refuses to submit. As a workaround I tried to use Display templates with the goal of achieving something like this
My @foreach
loop contains this
@Html.DisplayFor(modelItem => myModel.myString, "HtmlString")
My DisplayTemplate contains this
HtmlString.cshtml
@model String
@{
new HtmlString(@Model);
}
So if myString = "<ul><li>my text</li></ul>"
I would like my ajax form to display
- my text
What I have now doesn't work and returns nothing. Please help with what I'm doing wrong.