How do build a composite or template control in AS

2019-04-14 22:33发布

In our current ASP.Net Webforms application we have several composite/template server controls that only exist for a common look and feel. For example, we have a panel control that has a title, a place for buttons related to the contents of the panel, and of course the contents. How is this best accomplished in MVC? RenderPartial doesn't get done what I need here. Should I still be using the same controls, but just on a view page? These controls don't really do anything on postback, they are only there for a common look and feel.

More Info:

We have a control in Webforms that implements ICompositeControl. We have a few properties on this control like Panel (type Panel), Buttons (again type Panel which would hold buttons) and a property Title of type string. Visually it looks like

alt text

2条回答
The star\"
2楼-- · 2019-04-14 23:03

I'm a little hazy about the exact requirements here but i'f I understand this correctly then you want a control that has say title information with variable content such as static text, controls, images etc etc.

If I had to have a control that acted as a container for content, no matter what that content was, I think I'd consider a Html Helper that I could pass information to and it could make the assessment on what content to render.

It could then either call another helper, render a partial view or whatever.

查看更多
【Aperson】
3楼-- · 2019-04-14 23:08
登录 后发表回答