It is performing a Postback because you have an OnSelectedIndexChanged event on your RadioButtonList and by default your "Accept" value is Selected (so when you selected "Reject" the value is
changing so your event is being thrown).
Remove the "Selected" option on "Accept" by default and it should work properly :
According to following post there's an issue with list controls like RadioButtonList or CheckBoxList used as trigger for an UpdatePanel. The full postback happens because the trigger registers the list container as an asynchronous control but the postback
is fired by a child control with a different id. I've added this issue to the
unofficial bug/issue list.
You need do registerAsyncPostBackControl each time in page load phase. Or you can try the client-side appraoch.
Define html checkbox input control. In onchange event, you can call $get('id'') .style.display="none"/"block"; to show or hide the panel and update the updatepanel via the client-side approach.
shahas_sss
Member
176 Points
183 Posts
Selected value of Radio button list is not postbacking after use of Update Panel.
Feb 16, 2013 12:01 PM|LINK
Dear all,
SelectedIndexChanged event of radiobutton list is not working for me if i select 'selected item' from a list of items.
Please find the code below.
<asp:RadioButtonList ID="rbl1" runat="server" RepeatDirection="Horizontal"
OnSelectedIndexChanged="rbl1_SelectedIndexChanged" AutoPostBack="True">
<asp:ListItem Selected="True" Value="ACCEPT">Accept</asp:ListItem>
<asp:ListItem Value="REJECT">Reject</asp:ListItem>
</asp:RadioButtonList>
-------
<asp:UpdatePanel runat="server" ID="UpdatePanel1" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="rbl1" />
</Triggers>
<ContentTemplate>
<table>
<tr>
<td align="left">
<asp:Label ID="lbl1" runat="server" Style="position: static" Text=" Reason:"></asp:Label>
</td>
<td>
<asp:DropDownList ID="ddlCode" runat="server" Width="200px">
</asp:DropDownList>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
If i select 'Reject' then it is postbacking,if i select 'Accept' it not post backing.If i remove update panel then working fine.
Please give a solution.
Rion William...
All-Star
27916 Points
4618 Posts
Re: Selected value of Radio button list is not postbacking after use of Update Panel.
Feb 16, 2013 12:15 PM|LINK
It is performing a Postback because you have an OnSelectedIndexChanged event on your RadioButtonList and by default your "Accept" value is Selected (so when you selected "Reject" the value is changing so your event is being thrown).
Remove the "Selected" option on "Accept" by default and it should work properly :
shahas_sss
Member
176 Points
183 Posts
Re: Selected value of Radio button list is not postbacking after use of Update Panel.
Feb 16, 2013 05:03 PM|LINK
Thank u for your reply,,,
But i need to make Accept as default selected value.What can i do??
Rion William...
All-Star
27916 Points
4618 Posts
Re: Selected value of Radio button list is not postbacking after use of Update Panel.
Feb 16, 2013 09:40 PM|LINK
Have you tried placing your RadioButtonList within your ContentTemplate of your UpdatePanel?
<ContentTemplate> <asp:RadioButtonList ID="rbl1" runat="server" RepeatDirection="Horizontal" AutoPostBack="True" onselectedindexchanged="rbl1_SelectedIndexChanged"> <asp:ListItem Value="ACCEPT" Selected="True">Accept</asp:ListItem> <asp:ListItem Value="REJECT">Reject</asp:ListItem> </asp:RadioButtonList> <!-- Additional Content Here --> </ContentTemplate>chetan.sarod...
All-Star
65839 Points
11163 Posts
Re: Selected value of Radio button list is not postbacking after use of Update Panel.
Feb 18, 2013 03:05 AM|LINK
Refer this thread
http://blogs.msdn.com/b/mikeormond/archive/2007/03/26/the-curious-case-of-the-radiobuttonlist-not-triggering.aspx
According to following post there's an issue with list controls like RadioButtonList or CheckBoxList used as trigger for an UpdatePanel. The full postback happens because the trigger registers the list container as an asynchronous control but the postback is fired by a child control with a different id. I've added this issue to the unofficial bug/issue list.
http://forums.asp.net/t/1015714.aspx
You need do registerAsyncPostBackControl each time in page load phase. Or you can try the client-side appraoch.
Define html checkbox input control. In onchange event, you can call $get('id'') .style.display="none"/"block"; to show or hide the panel and update the updatepanel via the client-side approach.
http://vincexu.blogspot.com/2008/10/when-you-do-postback-via-control-which.html
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.