How do I create composite or templated controls in ASP.Net MVC or equivalent?

In our current ASP.Net Webforms application, we have a few composite / templated server controls that only exist for the regular look and feel. For example, we have a control panel that has a title, space for buttons associated with the panel's content, and of course, content. What's the best way to accomplish this in MVC? RenderPartial doesn't do what I need here. Should I be using the same controls, but only on the view page? These controls don't actually do anything on postback, they are only available for the normal view.

Additional Information:

We have a control in Webforms that implements ICompositeControl. We have several properties for this control, such as Panel (of type Panel), Buttons (re-enter the Panel that will contain the buttons) and the Title of type string property. Visually, it looks like

alt text

+2


a source to share


2 answers


Templated partial views are the way to go.



+2


a source


I'm a little vague about the exact requirements here, but if I understand this correctly, you need a control that speaks title information with variable content like static text, controls, images, etc. etc.

If I had a control that acted as a container for content, no matter what that content is, I think I would consider an Html Helper in which I could pass information, and it could evaluate that , visualization.



He can then call another helper, do a partial view, or whatever.

0


a source







All Articles