I have a webpage with 3 UpdatePanels on. They all work perfectly and have used UpdatePanels for years now and never come across this issue.
The RadioButtonList is posting back the entire page rather than the UpdatePanel and can’t see any errors in the output. I have never seen this behaviour before and copied the code into another project, and it worked as expected. All other controls on the page are working as expected in the same format.
Is there any other reasons that this behaviour could occur? My code below:
ASPX Code:
<asp:RadioButtonList ID="rbSelectWeek" runat="server" ClientIDMode="Static" CssClass="rb-select" OnSelectedIndexChanged="rbSelectWeek_SelectedIndexChanged" AutoPostBack="true" >
<asp:ListItem Text="Previous" Value="1" />
<asp:ListItem Text="Current" Value="2" Selected="True" />
<asp:ListItem Text="Next" Value="3" />
<asp:ListItem Text="All" Value="4" />
</asp:RadioButtonList>
<asp:UpdatePanel ID="upCaseViewer" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:HiddenField ID="dtFrom" runat="server" ClientIDMode="Static" Value="1900-01-01" />
<asp:HiddenField ID="dtEnd" runat="server" ClientIDMode="Static" Value="9999-12-31" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="cmbTeam" EventName="SelectedIndexChanged" />
<asp:AsyncPostBackTrigger ControlID="rbSelectWeek" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
VB.Net / C#
Protected Sub rbSelectWeek_SelectedIndexChanged(sender As Object, e As EventArgs) Handles rbSelectWeek.SelectedIndexChanged
Dim sVal As Integer = rbSelectWeek.SelectedValue
rbSelectWeek.ClearSelection()
rbSelectWeek.SelectedValue = sVal
Select Case sVal
Case 1
dtFrom.Value = getFunctions.getPrevWeek("Start")
dtEnd.Value = getFunctions.getPrevWeek("End")
Case 2
dtFrom.Value = getFunctions.getCurrWeek("Start")
dtEnd.Value = getFunctions.getCurrWeek("End")
Case 3
dtFrom.Value = getFunctions.getNextWeek("Start")
dtEnd.Value = getFunctions.getNextWeek("End")
Case Else
dtFrom.Value = getFunctions.getAll("Start")
dtEnd.Value = getFunctions.getAll("End")
End Select
End Sub
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
AsyncPostBackTriggers do not work when an referenced element uses ClientIDMode="Static". So change it to
<asp:RadioButtonList ID="rbSelectWeek" runat="server" CssClass="rb-select" OnSelectedIndexChanged="rbSelectWeek_SelectedIndexChanged" AutoPostBack="true" >
<asp:ListItem Text="Previous" Value="1" />
<asp:ListItem Text="Current" Value="2" Selected="True" />
<asp:ListItem Text="Next" Value="3" />
<asp:ListItem Text="All" Value="4" />
</asp:RadioButtonList>
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0