When does a radio button selection change not trigger an update?

When the radio button selection changes, I would like to show / hide the pane in the next cell of the table. I have it hiding and showing well, but every time it makes the page refresh to the top. Is their way to stop this update? I would like to hide and show the panel dynamically.

<table>
<tr>
            <td>
                <asp:RadioButtonList runat="server" ID="rblPlayerStatus" AutoPostBack="true" >
                    <asp:ListItem>Free Agent</asp:ListItem>
                    <asp:ListItem>I have teammate</asp:ListItem>
                </asp:RadioButtonList>
            </td>
            <td>
                <asp:Panel runat="server" ID="pnlTeamMate">
                    <asp:Label runat="server" ID="lblTeamMate" Text="Choose Teammate" />
                </asp:Panel>
            </td>
        </tr>      
</table>

      

+2


a source to share


4 answers


Use the AJAX.ASP.Net library, then add a ScriptManager and UpdatePanel element. Anything contained in the UpdatePanel will be updated via AJAX, not a full page update.



+2


a source


Do you have server side logic based on which panels are shown and hidden. If so, you can use the update control panel. If it's just client side logic like

If the Free Agent chooses show FreeAgent Panel else Team Panel



use javascript or rather jquery to achieve the same.

0


a source


From your code, I can't see where you hide and show the panel. You can use the refresh panel, but this is best used when you need to get more information from the server.

If you just want to show and hide the panel, you can do it better with Javascript by adding some code to the OnClick event to set the panel's visibility css attribute. There are several google guides on how to do this. Something like this should be enough to get you started.

0


a source


The solution will either use AJAX (UpdatePanel and ScriptManager) or remove AutoPostback = true

and use JavaScript to show / hide the panel

0


a source







All Articles