my problem is the following
I have an instance of a class and a HtmlTextWriter.
Now i want to generate the Editor like in the View.
The HtmlHelper is present and the methods Editor, TextBox … too.
public class Class
{
public string Test { get; set; }
}
HtmlTextWriter writer = new HtmlTextWriter(new StringWriter());
Class a = new Class(); //
a.Test = "Lorem ipsum";
how can i do this to get a TextBox and all the goodness of Validations (DataAnnotations) ?
writer.Write(HtmlHelper.Editor(x => ....).ToString());
Have a nice day !
To get the DataAnnotations validation (using unobtrusive JS) you need a FormContext, which is created when you use the BeginForm helper.