【发布时间】:2011-10-31 05:16:15
【问题描述】:
我在我的应用程序中使用 radrotator,如何从 asp.net c# 代码后面更改边框颜色或旋转器选定项目的颜色,我可以期待一些帮助。
【问题讨论】:
我在我的应用程序中使用 radrotator,如何从 asp.net c# 代码后面更改边框颜色或旋转器选定项目的颜色,我可以期待一些帮助。
【问题讨论】:
您可以通过其他 CSS 类更改 RadRotator 控件及其项目的边框:
可以覆盖内部 CSS 类 rrClipRegion 以便为旋转控件的边框设置新颜色:
.rrClipRegion
{
border: 1px solid green !important;
}
您可以通过 CSS 为 RadRotator 的项目设置默认边框颜色,然后您可以通过定义具有新边框颜色的 CSS 类从后面的代码中更改它,如下所示:
RadRotator 标记:
<telerik:RadRotator ID="RadRotator1" runat="server" FrameDuration="3000" ScrollDirection="Left"
Height="123px" ItemHeight="113px" Width="180px" ItemWidth="152px" Skin="Default"
RotatorType="Buttons" OnItemClick="RadRotator1_ItemClick">
<ItemTemplate>
<div>
<img src="....." alt="" />
</div>
</ItemTemplate>
</telerik:RadRotator>
应用边框所需的样式:
<style type="text/css">
.rrItem
{
margin: 4px;
}
.rrItem img
{
border: 1px solid grey;
}
.cssSelectedItem img
{
border: 1px solid red;
}
</style>
从代码隐藏更改项目的边框颜色:
protected void RadRotator1_ItemClick(object sender, RadRotatorEventArgs e)
{
RadRotatorItem item = (RadRotatorItem)e.Item;
item.CssClass = "cssSelectedItem";
RadRotator1.InitialItemIndex = e.Item.Index;
}
请注意,我设置了旋转控件的 InitialItemIndex 属性,以便通过回发保留当前项目。此外,该示例是为尺寸为 150x113 的图像设计的,因此如果使用不同的尺寸,您应该更改属性 Width、Height、ItemWidth , ItemHeight 相应地。
【讨论】: