我有一个简单的命令事件,可以切换两个按钮的可见性。
当控件包装在如下所示的更新面板中时,即使代码按预期执行,每次后续单击也不会切换按钮的可见性。
测试
upd.update
和updateMode="always"
ASPX
<asp:UpdatePanel ID="upd" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Repeater ID="rpt" runat="Server">
<ItemTemplate>
<asp:Button ID="btnOn" runat="Server" Text="ON" CommandName="ON" CommandArgument='<%#: Container.ItemIndex%>' UseSubmitBehavior="false" />
<asp:Button ID="btnOff" runat="Server" Text="OFF" CommandName="OFF" CommandArgument='<%#: Container.ItemIndex%>' UseSubmitBehavior="false" />
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
</asp:UpdatePanel>
VB.NET
Protected Sub Page_PreRenderComplete(sender As Object, e As EventArgs) Handles Me.PreRenderComplete
For Each item In rpt.Items
'Do a check and set output'
btnOn.Visible = Not Output
btnOff.Visible = Output
Next
End Sub