Home > DeveloperSection > Forums > RadioButton inside Update Panel causing postback
Jeet Verma
Jeet Verma

Total Post:110

Points:776
Posted on    February-04-2014 5:48 AM

 C# C# 
Ratings:


 1 Reply(s)
 3017  View(s)
Rate this:

I am putting the following controls inside an update panel so that the whole page does not refresh. When clicking the button, the page does not refresh but when I try to change the radio button, the page refreshes and causes a full postback. Here is my code:

<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager" runat="Server" EnablePartialRendering="true" />

<asp:UpdatePanel ID="updatePanelToggle" runat="server">

    <ContentTemplate>

        <asp:RadioButton ID="radioOn" AutoPostBack="true" runat="server" GroupName="toggle" Text="On" OnCheckedChanged="radioOn_CheckedChanged" />

        <asp:RadioButton ID="radioOff" AutoPostBack="true" runat="server" GroupName="toggle" Text="Off" OnCheckedChanged="radioOff_CheckedChanged" />

        <asp:Button ID="testButton" runat="server" OnClick="mybutton_click"/>

    </ContentTemplate>

</asp:UpdatePanel>



Pravesh Singh

Total Post:411

Points:2881
Posted on    February-04-2014 6:00 AM

Hi Jeet,

Depending on your requirement you can control post backs by adding triggers. Use AsyncPostBackTrigger when you want to update only the update panel content. If you need full post back use PostBackTrigger.

<asp:UpdatePanel ID="updatePanelToggle" runat="server" UpdateMode="Conditional">

    <ContentTemplate>

        <asp:RadioButton ID="radioOn" AutoPostBack="true" runat="server" GroupName="toggle" Text="On" OnCheckedChanged="radioOn_CheckedChanged" />

        <asp:RadioButton ID="radioOff" AutoPostBack="true" runat="server" GroupName="toggle" Text="Off" OnCheckedChanged="radioOff_CheckedChanged" />

        <asp:Button ID="testButton" runat="server" OnClick="mybutton_click"/>

    </ContentTemplate>

   <Triggers>

        <asp:AsyncPostBackTrigger ControlID="radioOn" />

        <asp:AsyncPostBackTrigger ControlID="radioOff" />

        <asp:PostBackTrigger ControlID="testButton" />

    </Triggers>

</asp:UpdatePanel>


Don't want to miss updates? Please click the below button!

Follow MindStick