我正在使用更新面板。在此更新面板中,有一個列表框控件。我實際上在後面的代碼中將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