I tried this as a simple test:
@functions {
private MvcHtmlString helloWorld()
{
return Html.EditorFor(m => m.Work.Description);
}
}
<script type="text/javascript">console.log(@helloWorld().ToString());</script>
However, the generated html that shows up is in the form of
<input class="text-box single-line" id="Work_Description"
name="Work.Description" type="text" value="" />
How can return a string which is the form of
<input class="test-box single-line" id="Work_Description" name="Work.Description"
type="text" value="" />
Use
@Html.Raw. Be aware that if helloWorld().ToString() contains dangerous code, it could be a security problem.