简体   繁体   English

Asp.Net MVC属性网格替换

[英]Asp.Net MVC Property Grid Replacement

I'm currently migrating an old forms application for MVC. 我目前正在为MVC迁移旧表格应用程序。 The forms application has a property grid, which automatically binds to an object. 表单应用程序具有属性网格,该网格自动绑定到对象。 The object has [Category] attributes assigned to each property. 该对象具有分配给每个属性的[Category]属性。 The object is also very complex. 该对象也非常复杂。

Is it better to build the View for this from scratch or use reflection to generate the UI. 最好是从头开始构建View还是使用反射来生成UI。 Personally, I prefer to build it using HTML, but the object is very big. 就我个人而言,我更喜欢使用HTML构建它,但是对象很大。 If it is still preferable to build the entire UI using @Html.TextBoxFor(), then that's the way I'll do. 如果仍然最好使用@ Html.TextBoxFor()构建整个UI,那么我将采用这种方式。

Also, I might end up creating a ViewModel for this, but that's a maybe. 另外,我可能最终为此创建了一个ViewModel,但这也许是可行的。

Thanks! 谢谢!

It depends! 这取决于! Do you have many similar objects that can benefit from reflection? 您是否有许多可以从反射中受益的类似物体? Is that code is going to be reused many times over in different views? 该代码是否将在不同的视图中多次重复使用? If yes, do reflection. 如果是,请进行反射。

Otherwise path down reflection will take you more time to work out. 否则,向下反射会花费您更多的时间进行锻炼。 And given that you already have required html, just use it! 鉴于您已经需要html,请使用它! Keep it simple. 把事情简单化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM