This is a migrated thread and some comments may be shown as answers.

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

1 Answer 42 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
AAA
Top achievements
Rank 1
AAA asked on 21 Nov 2013, 02:41 PM
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>

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 22 Nov 2013, 04:25 AM
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.
Tags
Ajax
Asked by
AAA
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or