Is it ok to render another view within an EditorTemplate in ASP.NET MVC?

Each view (be it a partial or not) has its own html helper Property. Using this property You can and call partial views to arbitrary depth. In your Situation I would suggest creating Display Template for comments because you are displaying them not editing them.It will create no difference in terms of functionality whatsoever but it violates the convention.

For example this is your display template for comments accepting IEnumerable %foreach(var x in Model){%> @x. CommentText x. CommentID)%> x.

CommentText)%> x. CommentText)%> x. Comments)) because it is a concern separate from displaying list of comments.

Each view (be it a partial or not) has its own html helper Property. Using this property You can and call partial views to arbitrary depth. In your Situation I would suggest creating Display Template for comments because you are displaying them not editing them.It will create no difference in terms of functionality whatsoever but it violates the convention.

For example this is your display template for comments accepting IEnumerable @x. CommentText Then you can have a partial view rendering the form to add new comment which you can place in another partial view called comment accepting Model of type Comment e. G x.

CommentID)%> x. CommentText)%> x. CommentText)%> I would personally call this view (rendering the form) from main view (from which I called Html.

DisplayFor(x=>x. Comments)) because it is a concern separate from displaying list of comments.

I would just create a partial view with: @model SomeModel @Html.EditorForModel() and use that if I needed to return PartialView() from an action method.

You can be lazy and use the same template by providing a model of an IEnumerable containing one comment. JQuery provides a way to pick out a fragment from an AJAX response. See "Loading Page Fragments" here.

Just add a selector for your one comment and add it to the list.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions