开发者

How do build a composite or template control in ASP.Net MVC, or the equivelant?

开发者 https://www.devze.com 2022-12-30 04:46 出处:网络
开发者_如何学PythonIn 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 h
开发者_如何学Python

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

How do build a composite or template control in ASP.Net MVC, or the equivelant?


Templated partial views is the way to go.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消