寻找一些实施建议:
我有一个页面,有一个 3-tab ajaxToolkit:TabContainer。该页面的目的是公开一个具有两个基本输入的计算器:地理位置和日期。这三个选项卡分别标记为“城市和州”、“邮政编码”和“GPS 坐标”。每个选项卡的每个选项卡容器的布局都相同,但位置部分除外;位置部分会发生变化,因为每种类型的位置都有不同的输入。例如,要指定城市/州,将有三个字段:城市、国家和州(国家和州将使用级联下拉列表)。但邮政编码仅需要一个字段(将通过正则表达式验证允许的国家/地区)。
请参阅示例设计模型:
因此,我想做的(为了最大限度地减少重复代码)是拥有一个包含计算器的布局和结构的通用控件,而不指定有关位置部分的任何内容。然后,我希望能够根据选择的选项卡引入每个独特的位置控件。选项卡结构存在于页面级别,而不是控件中。
有什么建议吗?
我正在查看模板化控件(请参阅 MSDN 文章 此处),但我不相信这是正确的解决方案。如果我必须创建三个具有相似布局和公共元素的独立控件,那么这就是我必须做的。但实际上,我更喜欢更优雅的、基于继承的解决方案。
任何建议将不胜感激。谢谢。
Looking for some implementation advice:
I have a page that has a 3-tab ajaxToolkit:TabContainer. The purpose of the page is to expose a calculator that has two basic inputs: geo-location and date. The three tabs are labeled "City and State", "Postal Code", and "GPS Coordinates". The layout of each tab container is the same for each tab, with the exception of the location section; the location section changes because each type of location has different inputs. For example, to specify city/state, there will be three fields: city, country, and state (country and state will use cascading drop-down lists). But Postal code requires only one field (which will validate via regular expression for allowed countries).
See the example design mockup:
So, what I WOULD LIKE to do (in order to minimize duplicate code), is to have a common control that contains the layout and structure of the calculator without specifying anything about the location section. Then, I'd like to be able to pull in each of the unique location controls based on what tab is selected. The tab structure exists at the page level, not in a control.
Any advice?
I was looking at templated controls (see MSDN article here), but I'm not convinced that it's the right solution. If I HAVE to create three separate controls with similar layouts and common elements, then that's what I have to do. But REALLY, I'd prefer a more elegant, inheritance-based solution.
Any advice would be greatly appreciated. Thanks.
发布评论
评论(1)
我最终使用 jQuery UI 来实现此目的。它的选项卡功能非常好。
I wound up using jQuery UI for this. It's tab feature is very nice.