如何在 javascript 中枚举 asp.net HTML 元素属性
为了使长篇故事尽可能短(如果您真的只想切入正题,请忽略本段):
我正在使用 CuteEditor 来编辑非常特定的控件页面。在页面查看器应用程序中,这些控件使用 HTML5 canvii 来执行各种时髦的动画操作,但在 CuteEditor 中(执行相同的操作并不实际),它们由 IMG 元素表示以实现可编辑性。这些控件有很多属性,这些属性都是从 SQL 数据库保存和加载的。不同类型的控件具有不同可能的属性类型,在 CuteEditor 中,这些属性存储为元素的属性(例如 PipColour="Green")。我为 CuteEditor IMG 编辑器对话框创建了一个自定义选项卡,当控件类型为更改后,将调用 SQL 数据库来获取所有可能的属性,以便可以用相关的输入控件填充对话框。
现在,追逐:
在 CuteEditor 中,自定义对话框选项卡使用带有 SyncToView() 和 SyncTo(element) javascript 方法的 .ascx 文件来获取和设置正在编辑的元素的属性,使用
element.<attributename>
“因为我不一定知道什么属性” element' 将具有或它们将被称为什么,有没有办法通过名称枚举它们?
To make a long story as short as possible (ignore this paragraph if you really just want to cut to the chase):
I'm using CuteEditor to edit very specific pages of controls. In the page viewer application these controls use HTML5 canvii to do all sorts of funky anim stuff, but in CuteEditor (where it's not practical to do the same thing) they are represented by IMG elements for editability. These controls have a bunch of properties, and this is all saved and loaded from an SQL database. Different types of control have different possible types of properties, and in CuteEditor these are stored as attributes of the element (such as PipColour="Green") I have created a custom tab for the CuteEditor IMG editor dialog, which when the control type is changed, an SQL database is called to get all the possible properties so the dialog can be populated with the relevant input controls.
Now, the chase:
In CuteEditor, custom dialog tabs use a .ascx file with SyncToView() and SyncTo(element) javascript methods to get and set the attributes of the element being edited, using
element.<attributename>
Since I don't necessarily know what attributes 'element' will have or what they will be called, is there a way to enumerate through them all by name?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用以下代码片段,它将为您提供获取属性的基本概念
You can use the following code snippet, it will give you the basic idea of getting Attributes