我有以下中继器控件,它绑定到DashboardPage对象的集合。 DashboardPage具有以下属性:名称,页码。将控件的ID属性绑定到对象属性
<asp:Repeater ID="reportPages" runat="server">
<ItemTemplate>
<asp:ImageButton runat="server" onclick="ImageButton_Click"
ImageUrl="<%# GetImagePath(Container.DataItem) %>"
onmouseover="<%# GetMouseOverEventString(Container.DataItem) %>"
onmouseout="<%# GetMouseOutEventString(Container.DataItem) %>"
/>
</ItemTemplate>
<SeparatorTemplate>
</SeparatorTemplate>
</asp:Repeater>
我想的ImageButton的ID属性绑定到命名DashboardPage对象,像这样
ID="<%# Eval('Name') %>"
的财产,但抛出一个异常:
控件的ID属性可以只能使用标签中的ID属性和一个简单的值进行设置。
我需要图像的ID属性,因为我有一个客户端脚本,它使用它的ID来更改图像。有没有解决的办法?
感谢答复
问候 加吉克Kyurkchyan
那为什么你没有ID = YourIMageID您的图像按钮 – BizApps 2011-12-19 08:22:40
为什么不使用的CssClass或类或自定义属性而不是ID,注意:如果您在中继器项目上使用ID,则ID将以容器的ID加上下划线作为前缀,具体取决于级别 – jerjer 2011-12-19 08:28:49
而不是使用usin g数据绑定#,你有没有试过使用=? <%= Eval('Name')%> – TheGeekYouNeed 2011-12-19 08:46:06