c# - When using MVC code first with data annotations how do you include html markup in the display name? -


i converting paper form mvc 4 web form. have questions paragraph worth of text include superscript numbers link footnotes. trying do:

public class paperformmodel {     [display(name = "full paragraph of question text copied straight           off of paper form<a href="#footnote1"><sup>footnote 1</sup></a>           , needs include formatted superscript           and/or link footnote text.")]     public string question1 { get; set; }      // more properties go here ... } 

after creating model generated controller , related views. works except html markup in display name converted html encoded text (i.e. &lt;sup&gt;1&lt;/sup&gt;). code in view.cshtml used display property automatically generated code:

<div class="editor-label">     @html.labelfor(model => model.question1) </div> <div class="editor-field">     @html.editorfor(model => model.question1)     @html.validationmessagefor(model => model.question1) </div> 

i trying figure out how html markup footnotes work or approach somehow wrong , should doing different way? first mvc project , coming asp.net background.

i think should try move html text resources , apply model next code:

public class paperformmodel {         [display(resourcetype = typeof(paperformmodelresources), name = "question1fieldname")]     public string question1 { get; set; }      // more properties go here ... } 

to create resource file:
- create resources folder in solution if not exist.
- right click on folder in solution explorer -> add -> resource file or ... -> add -> new item , select resource file
- name file paperformmodelresources
- add new entry name question1fieldname , value full paragraph of question text copied straight off of paper form<a href="#footnote1"><sup>footnote 1</sup></a> , needs include formatted superscript and/or link footnote text. using resource manager.

edits: if, result, html markup not displayed correctly (it displayed plain text) can use answer this question is:

<div class="editor-label">     @html.raw(httputility.htmldecode(html.labelfor(model => model.question1).tohtmlstring)) </div> <div class="editor-field">     @html.editorfor(model => model.question1)     @html.validationmessagefor(model => model.question1) </div> 

hope helped.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -