經過幾個小時的調試此問題(請參閱標題)我訴諸於互聯網。爲了提前說明,是的,我已經在創建這個問題的同時閱讀了「具有類似標題的問題」。雖然他們提供了一些很好的見解,但尚未達成解決方案。控制在SelectIndexChanged上UpdatePanel的可見性
下面是基本事件映射:
- 頁負載,RadioListBox的第一索引[0]被設置爲選擇= 「真」。
- 用戶選擇其它索引,如果選擇一個特定的項目值,設置 知名度爲「true」後續面板的
我是相當新的ASP.NET AJAX的世界,所以任何和所有的建議是讚賞。除非你告訴我吃便便,否則我可能不會理解這一點。
這裏是代碼,後面跟着我調試過的步驟。
標記:(是的,我知道字段集裏面沒有表單標籤是不是語義,我會擔心以後)
<asp:UpdatePanel runat="server" ID="updpnlDDCancelPartnerOpts" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel runat="server" CssClass="frmDDCancelPartnerOpts">
<fieldset>
<legend>Digital Cancellation Options:</legend>
<br />
<asp:RadioButtonList ID="rdlstCancellOptions" runat="server" AutoPostBack="true"
cssclass="rdBtnLstDDCancelOpts" onselectedindexchanged="rdlstCancellOptions_SelectedIndexChanged">
<asp:ListItem Value="cancelall" Selected="True">Cancel ALL Digital Distribution:</asp:ListItem>
<asp:ListItem Value="canceldotcom">Cancel CD Baby ONLY:</asp:ListItem>
<asp:ListItem Value="partnercancellations">Cancel From Specific Partners:</asp:ListItem>
</asp:RadioButtonList>
</fieldset>
</asp:Panel>
<asp:Panel runat="server" ID="pnlChecks" CssClass="partner">
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="rdlstCancellOptions" EventName="SelectedIndexChanged"/>
</Triggers>
</asp:UpdatePanel>
代碼隱藏:(我只是發佈事件的方法,如果你希望看到更多的,只是問:)
protected void rdlstCancellOptions_SelectedIndexChanged(object sender, EventArgs e)
{
if (rdlstCancellOptions.SelectedValue == "partnercancellations")
{
pnlChecks.Visible = true;
updpnlDDCancelPartnerOpts.Update();
}
}
Debuggin':
我已經包裹在單獨的UpdatePanel每個(RLB的控制和pnlChecks面板),我已經使用觸發器和沒有使用過,WI幾乎每一個AutoPostBack的組合。最重要的是,當在事件函數上設置一個斷點時,它會觸發它,遍歷它,然後返回到頁面 - 而不刷新並將pnlChecks面板設置爲可見。
ScriptManager包含在MasterPage中。
我知道我可能會遺棄大量的信息。然而,現在已經很晚了,經過17個小時的工作時間(不是所有的17個小時都花在這個上面),我再也不能強迫自己的目光盯着電腦屏幕。
所以,如果有什麼(很可能是顯而易見的),我錯過了,請隨時分享。 +百萬互聯網!
Koohoy0x
如果是這樣,請將其標記爲答案 –