selecting radiobutton does a full page submit (instead of ajax)

2 posts, 0 answers
  1. AAA
    AAA avatar
    17 posts
    Member since:
    Mar 2013

    Posted 21 Nov 2013 Link to this post

    I have two radio buttons on my aspx page, and when I click one, it does a full page submit. I need to implement Ajax functionality. How can I do that?  

    On my html page, I have a reference to the AjaxToolkit. Any suggestion?

    The html code is:    

    <asp:Panel ID="pnlSelectAllItemsClearAllItems" Visible="true" runat="server" ScrollBars="None">
        <table border="0">
            <tr>
                <td width="50%" style="height:2%;">
            <asp:RadioButtonList ID="rbSelectAllItemsClearAllItems" runat="server" AutoPostBack="true"
                RepeatDirection="Horizontal"  Enabled="true"
                OnSelectedIndexChanged="rbSelectClearAllItems_OnSelectedIndexChanged" >
                <asp:ListItem Value="SelectAllItems">Select All Items</asp:ListItem>
                <asp:ListItem Value="ClearAll">Clear All</asp:ListItem>
            </asp:RadioButtonList>
                </td>
                <td style="text-align: center; height:2%;" width="50%">
                    <asp:Button runat="server" Text="Archive Selected Items"
                        ID="btnArchiveSelected" onclick="btnArchiveSelected_Click" />    
                </td>
            </tr>
        </table>
    </asp:Panel>
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 21 Nov 2013 Link to this post

    Hi AAA,

    Please have a look into the sample code snippet.

    ASPX:
    <asp:Panel ID="pnlSelectAllItemsClearAllItems" Visible="true" runat="server" ScrollBars="None">
        <table style=" border :0;">
            <tr>
                <td style="height: 2%; width : 50%;">
                    <asp:RadioButtonList ID="rbSelectAllItemsClearAllItems" runat="server" AutoPostBack="true"
                        RepeatDirection="Horizontal" Enabled="true" OnSelectedIndexChanged="rbSelectAllItemsClearAllItems_SelectedIndexChanged">
                        <asp:ListItem Value="SelectAllItems">Select All Items</asp:ListItem>
                        <asp:ListItem Value="ClearAll">Clear All</asp:ListItem>
                    </asp:RadioButtonList>
                </td>
                <td style="text-align: center; height: 2%; width: 50%">
                    <asp:Button runat="server" Text="Archive Selected Items" ID="btnArchiveSelected" />
                </td>
            </tr>
        </table>
    </asp:Panel>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="rbSelectAllItemsClearAllItems">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="Panel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <asp:Panel ID="Panel1" runat="server" Style="border: 1px solid black; height: 100px;
        width: 150px;">
        <asp:Label ID="Label1" runat="server" Text="Ajaxified">
        </asp:Label>
    </asp:Panel>
     
    C#:
    protected void rbSelectAllItemsClearAllItems_SelectedIndexChanged(object sender, EventArgs e)
    {
        Label1.Text = rbSelectAllItemsClearAllItems.SelectedItem.Text;
    }

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top