4imble
4imble

Reputation: 14416

Anyone had success with EditorFor Templates using FluentHtml?

I know it's a long shot, but i wondered if anyone has had any success with using FluentHtml inside an editorFor Template.

Specifically, getting the prefixes to work so that the viewmodel binds back when submitted.

<%: Html.EditorFor(model => model.Client, "ClientTemplate", new { editing = false })%>

The above for example would prefix all the form html input (Name's and Id's) with Client, so that it will bind back correctly. But when using fluent this is not the case.

An example of some Fluent Html.

<%= this.TextBox(model => model.Name)
         .Disabled(Model.IsDisabled)
         .Class("large")%>

At the moment, i am considering setting the Id manually with the prefix... but this is not ideal.

I could also remove the fluent Html but I then lose the ability to set "disabled" as nicely.

Upvotes: 0

Views: 350

Answers (1)

Tim Scott
Tim Scott

Reputation: 15205

If I understand what you are doing, this should work. In the markup, add:

<%this.HtmlNamePrefix = "Client"%>

Upvotes: 0

Related Questions