如何构建 ImageButton 控件适配器(或者更一般地说,如何构建一个简单的控件适配器)?
我提出这个问题的灵感是我发现 ImageButton Web 控件上非常烦人的默认样式 (border-width: 0px;
)。 简单的解决方案是通过向控件添加您自己的样式来覆盖它,例如 Style="border-width: 2px;"
。
无论如何,如果能够制作一个简单的控件适配器,它会在正确的位置介入并告诉控件不要呈现默认样式,那就太好了。
在查看了 CSSFriendly ControlAdapter 项目的代码后,似乎他们正在重新创建大部分渲染,这对于我想要做的事情来说有点过分了——即只需更改渲染出来的默认样式。
那么问题来了,如何通过控件适配器只修改默认样式的渲染,而其余部分保持原样?
有可能吗?
谢谢,埃吉尔。
My inspiration for this question was my discovery of the very annoying default style (border-width: 0px;
) on the ImageButton web control. The simple solution is to override it by adding your own style to the control e.g. Style="border-width: 2px;"
.
How every, it would have been nice to just make a simple control adapter that would just step in at the right place and just tell the control not to render the default styling.
After looking a bit at the code from the CSSFriendly ControlAdapter project, it seems like they are recreating much of the rendering, which is overkill for what I want to do -- i.e. just change the default styling that is rendered out.
So the question, how to just modify the rendering of the default styles through control adapters, and leave the rest as is?
Is it even possible?
Thanks, Egil.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有两种方法可以做到这一点。 两者都需要编写自定义控制适配器。 您可以在代码中设置实际值,也可以根本不包含该值,然后使用 CSS 来设置您的值。 这是执行此操作所需的代码。
然后您需要在浏览器文件之一中添加一个条目,如下所示
There are two ways to do this. Both will require writing up a custom Control Adapter. Either you can set the actual value in code, or you can just not include the value at all and then use CSS to set your value. Here's the code you'll need to do this.
Then you'll need to add an entry into one of your browser files like this