我正在使用更新面板。在此更新面板中,有一个列表框控件。我实际上在后面的代码中将autopostback属性设置为false。但如果所选索引改变,它仍然执行SelectedIndexChanged事件。发射SelectedIndexChanged事件,但列表框的autopostback属性为false - ASP.NET
为什么会发生这种情况?
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:MultiView ID="mvForms" runat="server" ActiveViewIndex="1">
<asp:View ID="View1" runat="server">
<asp:Panel ID="Panel5" runat="server" GroupingText="Available Evaluation Forms" meta:resourcekey="rsKey_panel5"
Width="100%">
<asp:ListBox ID="lbAvailableForms" runat="server" AutoPostBack="true"
style="height: 125px; width: 95%;"
onselectedindexchanged="lbAvailableForms_SelectedIndexChanged"></asp:ListBox>
</asp:Panel>
</asp:View>
<asp:View ID="View2" runat="server">
<asp:Panel ID="Panel11" runat="server" GroupingText="Available Evaluation Forms" meta:resourcekey="rsKey_panel11" Width="100%">
<div style="height: 125px; width: 95%; text-align:center;">
<br />
<br />
<asp:Label ID="lblAllSelected" runat="server" Text="All Selected" meta:resourcekey="rsKey_lblAllSelected"></asp:Label></div>
</asp:Panel>
</asp:View>
</asp:MultiView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="RLCompareParameter" EventName="SelectedIndexChanged"></asp:AsyncPostBackTrigger>
<asp:AsyncPostBackTrigger ControlID="cbAllForms" EventName="CheckedChanged"></asp:AsyncPostBackTrigger>
</Triggers>
</asp:UpdatePanel>
列表框名称是lbAvailableForms。在调试时,我检查了这个列表框控件的autopostback属性,然后我发现该属性为false。它看起来很奇怪,然后如何selectedindexchanged事件触发
这里cbAllForm是一个复选框控件,RLCompareParameter是一个radilo列表。
有时我需要得到自动回发属性是正确的。所以最初我把这个属性设置为true。在RLCompareParameter_SelectedIndexChanged事件下,我设置了lbAvailableForms.Autopostback = false。但在将属性设置为false后,列表框触发选定的indexchanged事件
请发布您的代码的相关部分。请注意,在执行普通回发后,SelectedIndexChanged也会触发。 – cbp 2010-11-01 06:21:51
谢谢你的回复。我添加了一些代码。 – 2010-11-01 06:33:55
什么是'cbAllForms'?如果将'UpdatePanel1'的[ChildrenAsTriggers](http://msdn.microsoft.com/zh-cn/library/system.web.ui.updatepanel.childrenastriggers.aspx)属性设置为'false',问题是否会持续存在? – 2010-11-01 06:45:20