开发者

two forms or one form with conditional logic

Currently have a form with a ListView.

Users of role A get an image when in ViewMode.

Users of role B get an image when in EditMode.

Is it better to create two clean forms with proper markup, or create one form with conditional logic? The image will be an HTML img, with no runat=server. If I do one form and add the imag开发者_C百科e to both ItemTemplate and EditItemTemplate, I need to programmatically remove the image by editing the LiteralControls or adding Javascript depending on the role. If I do two forms, the proper role will get the proper form, but will have two forms to maintain.


The form should be treated as the 'view', so you could have your controller create the appropriate view on one form based on the user role, as recommended in the Model-View-Controller (MVC) paradigm.

I hope this helps


I'm never a fan of duplicating work, simply because of the problems it creates for maintenance in the future. In this situation, I would prefer one form, with logic in the code behind to determine whether the image control should be displayed.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜