更改代码隐藏中重复器项目的样式?
只是想知道是否有办法从代码隐藏中更改重复项目的样式/CSS。基本上我有一个页面的打印机友好版本,如果显示器是打印机友好的,我想为中继器中的每个项目添加底部边距。这可能吗?
just wondering if there is a way to change the style/css of repeateritems from the codebehind. Basically I have a printer friendly version of a page and if the display is printer friendly i want to add a bottom margin to each item in the repeater. Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
是的,可以在 中执行Repeater 的 ItemDataBound 事件。
Yes, it is possible to do within the ItemDataBound event of the Repeater.
有多种应用样式的选项,请查看 Repeater 的 ItemDataBound 事件。
隐藏代码:
aspx:
There are several options to apply styles, hae a look at thee Repeater's ItemDataBound event.
codebehind:
aspx:
是的,你可以。你在重复什么?
?一个
?
只需从后面的代码更改 CssClass ... 例如:YourRepeatedItem.CssClass =“PrinterFriendly”。
Yes you can. What are you repeating ? a
<TR>
? a<DIV>
?Just change the CssClass from code behind ... ex : YourRepeatedItem.CssClass = "PrinterFriendly".
可以从代码隐藏中更改任何控件的样式。基本上,WebControl 类(所有 ASP.NET UI 控件的父级)具有 CssClass 属性和许多其他公开样式行为的属性。通过更改它们,您可以改变外观。
it is possible to change styles of any control from the codebehind. Basically the WebControl class ( the parent of all the asp.net UI controls ) is having the CssClass property and many other properties that expose the style behaviors. By changing them you can change the look.
您可能还想利用样式表中提供的“media”属性:http:// /www.javascriptkit.com/dhtmltutors/cssmedia.shtml
或
You may also want to make use of the 'media' property that is available in style sheets: http://www.javascriptkit.com/dhtmltutors/cssmedia.shtml
OR