动态更改 fieldset html 标签(或 div,或任何标签)的内容。
我正在为一个项目创建一个“设置”网页(在 VS 2010 下使用 asp.net Framework 3.5)。
页面上有 2 个字段集:
第一个)作为带有名为“配置”、“数据输出格式”等按钮的菜单
第二个)用于显示特定所选菜单项的 Web 控件集。
问题:
正如您可以猜到的,我需要动态更改第二个字段集的内容。 通过在互联网上搜索,我有两个选择:
1) 为每个菜单项创建带有 Web 控件的单独网页,并通过使用 iframe 标记将它们显示在“设置”网页上
2) 为每个菜单项选择编写类似 fieldset.innerHtml = "VERY long long long string line with html code" 的内容。这将是几个如此长的字符串行导致“设置”页面上有多个可用选项。
那么,开发人员,您建议我做什么?
也许存在 3 种方法可以避免使用 iframe 和编写长而尴尬的难以维护的 html 代码字符串行?
I'm creating a "Settings" web-page for a project (using asp.net framework 3.5 under VS 2010).
There is 2 fieldsets on the page:
the first) as menu with buttons that are named "Configuration", "Data output formats", etc
the second) for showing set of web-controls for particular chosen menu item.
The question:
As you can guess I need to change dynamically the content of that second fieldset.
By had searched in the internet I came to 2 choices:
1) create separate web-pages with web-controls for each of menu item and show them on the Settings web-page via use of iframe tag
2) write something like fieldset.innerHtml = "VERY long long long string line with html code" for every menu item choice. And it will be several such very long string lines caused several options available on the Settings page.
So what would you advise me to do, developers?
Maybe it exists the 3 way to do this that allows to avoid of using iframes and writing long awkward hard-to-maintain string lines of html code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不熟悉 ASP,但是,您不能在单独的文件中为每个菜单项的控件编写 HTML 代码并执行某种条件 服务器端包含?
如果没有,您始终可以在单个 asp 页面中构建服务器端元素。
I'm not familiar with ASP, but, couldn't you just code the HTML for the controls of each menu item in a separate file and perform some kind of conditional server-side inclusion?
If not, you could always build your elements server-side in a single asp page.
还有第三种方法,您可以使用所需的所有字段制作页面,其中一个用于“配置”的字段集,另一个用于“数据输出格式”的字段
集,等等...然后,当您单击按钮,它会隐藏所有其他字段集并仅显示所需的字段集。
更容易维护,而且不需要向服务器做任何额外的请求
There's a third way, you can make your page with all the fields that you need, having a fieldset for "Configuration", another for "Data Output Formats", etc...
Then you play with the visibility, when you click on the buttons it hides all the other fieldsets and shows only the desired one.
It's easier to maintain, and you don't have to do any extra requests to the server