Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Episerver 7 MVC Render Xform issue

Vote:
 

Hi All,

Current Days, I am working on Xforms by using Episerver 7 MVC. I have met a few problems and the most difficult thing is how to render xforms correct.

For example, the bold area is what I wanted.

<label title="<%: Model.Title %>">
    <%: Html.DisplayFor(model => model.Label) %>
    <%: Html.TextBox(Model.Reference, Server.HtmlDecode(Model.Value) ?? string.Empty, new { size = Model.Size })%>
    <%: Html.ValidationMessage(Model.Reference)%>
</label>

<label title="<%: Model.Title %>">
    <%: Html.DisplayFor(model => model.Label) %>
</label>

<%: Html.TextBox(Model.Reference, Server.HtmlDecode(Model.Value) ?? string.Empty, new { size = Model.Size })%>
<%: Html.ValidationMessage(Model.Reference)%>

I reseach in forums and can only find to the way to rewrite html.displayModel method. But it is hard to rearrange the element on the form.

Then I find in my local path:C:\Program Files (x86)\EPiServer\CMS\7.0.586.1\Application\Util\Views\Shared\EditorTemplates. There are some editor templates in the folder and of course we can change its tag and sequence. But if we upgrade to a new version, the files could be override and it is not a good solution.

If you find some useful methods, please give me a sample please.

 

#73903
Aug 14, 2013 8:55
Vote:
 

If you have implemented a custom view engine (like in the Alloy MVC template), you can hook up an additional partial view location format that points to "~/Views/Shared/EditorTemplates/{0}.cshtml". After that you should be able to drop razor views named like the ones from EPiServer in there and customize (take over, really) the rendering without messing about in the EPiServer’s program files folder.

For instance a file named "/Views/Shared/EditorTemplates/InputFragment.cshtml" in your case.

I’m assuming you are using Razor views in your project, but it should be easy to change the view to web forms using .ascx as the file extension if you for some reason really would like to.

 

#74909
Sep 11, 2013 13:06
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.