2017年3月31日 星期五

[MVC] Can RenderSection be used in EditorForModel ?

Q. Sections work only in views, not in partials. An editor template is a special kind of partial. It's bad practice to put javascript in partials anyway, so I would simply declare the section in the Edit.cshtmlview.
But if you very much insist on putting your scripts in the middle of your markup, since Razor doesn't support sections in partials, you could implement custom helpers to achieve that.

REF: http://stackoverflow.com/questions/10810446/rendersection-and-editorformodel-in-asp-net-mvc

沒有留言:

張貼留言