我在更新面板中有几个带有AsyncPostBackTrigger的按钮 更新面板之外是ListBox ListBox的OnSelectedIndexChanged应该检查条件,然后启用或禁用按钮。这不会奏效。
<asp:TableRow runat="server">
<asp:TableCell runat="server">
<asp:ListBox Rows="6" Width="200px" Height="50" ID="DrawingsListBox" OnSelectedIndexChanged="DrawingListBox_SelectedIndexChanged"
AutoPostBack="True" runat="server"></asp:ListBox>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="DeleteDrawingButton" Style="margin-left: 20px;" OnClick="DeleteDrawingButton_OnClick"
Text="Delete" runat="server" />
<asp:Button ID="DownloadDrawingButton" OnClick="DownloadDrawingButton_OnClick"
Text="Download" runat="server" /><br />
</ContentTemplate>
<Triggers><asp:AsyncPostBackTrigger ControlID="DrawingsListBox" EventName="SelectedIndexChanged" /></Triggers>
</asp:UpdatePanel>
</asp:TableCell>
</asp:TableRow>
Public Sub DrawingListBox_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles DrawingsListBox.SelectedIndexChanged
If (DrawingsListBox.SelectedIndex > -1) Then
DownloadDrawingButton.Enabled = True
DeleteDrawingButton.Enabled = True
Else
DownloadDrawingButton.Enabled = False
DeleteDrawingButton.Enabled = False
End If
End Sub
我已经在按钮上设置了其他属性(例如BackColor),它们工作正常。我发现的按钮上唯一没有找到的属性是Enabled属性。并且在调试时,显示在If Else之后,将Button.Enabled设置为True。我已经检查了代码中是否有其他内容导致这些内容无效,我无法找到任何内容。
基本上,按钮属性正在运行(Enabled除外),并且正在更新更新面板。所以我不知道发生了什么。
感谢您的帮助