我在不知情的情况下构建了一个在 IE 上激活兼容性 View 的 .net Web 应用程序。停用兼容性 View 不仅会使一切看起来一团糟,还会削减未触发事件的 LinkButton 的功能。
我正在通过按顺序填充转发器来构建日历。数据来自 SQL。
<asp:Repeater runat="server" id="RepeaterCalendar">
<ItemTemplate>
<asp:label ID="Month_lbl" runat="server" Text='<%# Bind("Month") %>'/>
<asp:label ID="Pretag_lbl" runat="server" Text='<%# Bind("PRETAG") %>'/>
<asp:LinkButton ID="ButtonSelect" runat="server" CommandName ="Select" CommandArgument = '<%# Eval("date") %>' Text='<%# Bind("TAG") %>' style="vertical-align:text-bottom" OnClick="GetDetails" Visible="true" />
<asp:label ID="Posttag_lbl" runat="server" Text='<%# Bind("POSTTAG") %>'/>
<asp:label ID="Monthend_lbl" runat="server" Text='<%# Bind("MonthEnd") %>'/>
</ItemTemplate>
</asp:Repeater>
关闭兼容性 View 后,LinkButton 不会触发该事件,而当再次打开兼容性 View 时它可以正常工作。
我想这与我使用 asp:repeater 粘合在一起形成日历表的所有断裂代码位有关。如果我绑定(bind)一个没有任何 html 标签的“普通”列,那么 LinkButton 将按预期工作;但这破坏了整个日历设计。
马丁
最佳答案
<asp:Repeater runat="server" id="RepeaterCalendar">
<ItemTemplate>
<asp:label ID="Month_lbl" runat="server" Text='<%# Bind("Month") %>'/>
<asp:label ID="Pretag_lbl" runat="server" Text='<%# Bind("PRETAG") %>'/>
<asp:LinkButton ID="ButtonSelect" runat="server" CommandName ="Select"
CausesValidation="false" CommandArgument = '<%# Eval("date") %>' Text='<%# Bind("TAG") %>' style="vertical-align:text-bottom" OnClick="GetDetails" Visible="true" />
<asp:label ID="Posttag_lbl" runat="server" Text='<%# Bind("POSTTAG") %>'/>
<asp:label ID="Monthend_lbl" runat="server" Text='<%# Bind("MonthEnd") %>'/>
</ItemTemplate>
</asp:Repeater>
使用 CausesValidation="false"
关于css - 关闭兼容性 View IE11 时链接按钮未触发的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41569266/