The RadAjaxManager do not fire postback with RadioButtonList

17 posts, 0 answers
  1. Ricky
    Ricky avatar
    247 posts
    Member since:
    Jun 2007

    Posted 06 Jan 2008 Link to this post

    Hi, I drop a RadioButtonList and set its default select index to 0. In normal postback (with RadAjaxManager) mechanism, everything goes well. But if I use RadAjaxManager to instruct it to upload another Control, selecting the first option will not fire postback, while selecting others goes normally. The code snippet is as follows:

        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="TimeOption_RadioList">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="Chart1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>

     <asp:Panel ID="filterRadio_Panel" runat="server"  DefaultButton="filterSubmit_Btn">
         <asp:RadioButtonList ID="TimeOption_RadioList" runat="server" RepeatDirection="Horizontal"
         OnSelectedIndexChanged="TimeOption_RadioList_SelectedIndexChanged"
         AutoPostBack="True" DataSource='<%#getTimeOptions() %>' DataTextField="key" DataValueField="value" OnDataBound="TimeOption_RadioList_DataBound" >

         </asp:RadioButtonList>
     </asp:Panel>


    Is this a common bug?

    Regards,
    Ricky.
  2. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 07 Jan 2008 Link to this post

    Hi Ricky,

    We could not reproduce the problem on our end. Find attached a sample project using your code. We would appreciate it if you modify it so that it exhibits the abnormality you have encountered.

    Looking forward to your reply.

    All the best,
    Steve
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ricky
    Ricky avatar
    247 posts
    Member since:
    Jun 2007

    Posted 07 Jan 2008 Link to this post

    Simply add Selected attribute to the first item, you will observe what I mentioned.
                   
    <asp:ListItem Selected="True">111</asp:ListItem>

    Ricky.
  5. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 09 Jan 2008 Link to this post

    Hello Ricky,

    This is a known problem, which is caused by the fact that setting Selected=true, changes the rendering for that item and it no longer attaches onclick attribute for it. To workaround this weird problem, you can set the wrapping asp:Panel as the initiator and updated controls instead:

      <asp:Panel ID="filterRadio_Panel" runat="server" DefaultButton="Button1">
                <asp:RadioButtonList ID="TimeOption_RadioList" runat="server" RepeatDirection="Horizontal"
                    OnSelectedIndexChanged="TimeOption_RadioList_SelectedIndexChanged" AutoPostBack="True">
                    <asp:ListItem Selected="True">111</asp:ListItem>
                    <asp:ListItem>222</asp:ListItem>
                    <asp:ListItem>333</asp:ListItem>
                    <asp:ListItem>444</asp:ListItem>
                </asp:RadioButtonList>
                <asp:Button ID="Button1" runat="server" />
                <asp:Label ID="Label1" runat="server"></asp:Label>
            </asp:Panel>

    Hope this helps.

    Greetings,
    Steve
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. Ricky
    Ricky avatar
    247 posts
    Member since:
    Jun 2007

    Posted 09 Jan 2008 Link to this post

    Strange enough. Could you provide me the articles or references about this issue?

    Appreciate very much.
    Ricky.
  7. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 09 Jan 2008 Link to this post

    Hi Ricky,

    We have not yet documented this one, but I am adding it in our TODO list right now. Thank you for bringing it up -  your Telerik points have been updated. Here is the difference between the selected item and the normal item in the RadioButtonList:

        <table id="RadioButtonList1" border="0">
        <tr>
            <td><input id="RadioButtonList1_0" type="radio" name="RadioButtonList1" value="111" checked="checked" /><label for="RadioButtonList1_0">111</label></td>
        </tr><tr>
            <td><input id="RadioButtonList1_1" type="radio" name="RadioButtonList1" value="222" onclick="javascript:setTimeout('__doPostBack(\'RadioButtonList1$1\',\'\')', 0)" /><label for="RadioButtonList1_1">222</label></td>
        </tr>
    </table>

    Notice how the first item is missing the onclick attribute, so the Ajax controls which rely on that cannot handle the event. It would work if you use the parent panel as initiator and updated control as the RadioButtonList postbacks internally on the selected item and this way the request is intercepted on panel level.

    Best wishes,
    Steve
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  8. Ricky
    Ricky avatar
    247 posts
    Member since:
    Jun 2007

    Posted 09 Jan 2008 Link to this post

    Understand the concept.
    Thanks for the explanation.

    Ricky.
  9. Ricky
    Ricky avatar
    247 posts
    Member since:
    Jun 2007

    Posted 09 Jan 2008 Link to this post

    Hi, if the updated control msut be outside the parent panel, this solution raised another problem, the re-select the first item (default selected one) will trigger normal postback.

    Ricky.
  10. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 10 Jan 2008 Link to this post

    Hi Ricky,

    Unfortunately there is no straightforward way to resolve this as it is .NET framework problem that is present in MS AJAX as well. Here is how your scenario would look like if using UpdatePanel:

     <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> 
            <asp:Panel ID="filterRadio_Panel" runat="server" DefaultButton="Button1"
                <asp:RadioButtonList ID="TimeOption_RadioList" runat="server" RepeatDirection="Horizontal" 
                    OnSelectedIndexChanged="TimeOption_RadioList_SelectedIndexChanged" AutoPostBack="True"
                    <asp:ListItem Selected="True">111</asp:ListItem> 
                    <asp:ListItem>222</asp:ListItem> 
                </asp:RadioButtonList> 
                <asp:Button ID="Button1" runat="server" /> 
            </asp:Panel> <asp:UpdatePanel ID="UpdatePanel1" runat="server"><ContentTemplate> 
            <asp:Label ID="Label1" runat="server"></asp:Label></ContentTemplate
                <Triggers> 
                    <asp:AsyncPostBackTrigger ControlID="TimeOption_RadioList" /> 
                </Triggers> 
            </asp:UpdatePanel> 

    As you can see the Selected ListItem does not fire its event here as well. The only possible reliable solution will be if you use standard RadioButtons grouped in your own "RadioButtonList" which of course would require some amount of logic applied.

    Kind regards,
    Steve
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  11. Ricky
    Ricky avatar
    247 posts
    Member since:
    Jun 2007

    Posted 10 Jan 2008 Link to this post

    Here is a workaround
    http://forums.asp.net/p/1015714/1944047.aspx, although not straightforward.

    FYI,
    Ricky
  12. Jeff
    Jeff avatar
    3 posts
    Member since:
    Jan 2007

    Posted 10 Apr 2008 Link to this post

    I just set the updated controls to point to the RadioButtonList and this seems to work.

    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="TimeOption_RadioList">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="Chart1" />
                       <telerik:AjaxUpdatedControl ControlID="TimeOption_RadioList" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
  13. Doug
    Doug avatar
    22 posts
    Member since:
    Feb 2005

    Posted 07 Jun 2009 Link to this post

    Jeff's solution solved my problem with this as well.  Thanks Jeff!
  14. Nicolaï
    Nicolaï avatar
    160 posts
    Member since:
    Apr 2008

    Posted 22 Mar 2011 Link to this post

    Yes, thanks Jeff!
  15. Pravin
    Pravin avatar
    1 posts
    Member since:
    Sep 2012

    Posted 17 May 2011 Link to this post

    Hi,

    I am having the same problem. I am using a radio button list in the user control  and rad manager is on the master page. I have added radio button list in asp:panel. User control gets loaded dynamically. How I can add it as "AjaxUpdatedControl" as control id will changed and will be depending on the consumer (the way asp.net generates id...).

    Is there any other way to resolve this issue. Let me know.

    Thanks,
    Pravin.
  16. Nicolaï
    Nicolaï avatar
    160 posts
    Member since:
    Apr 2008

    Posted 18 May 2011 Link to this post

    Sounds like you need to add ajax settings from code behind..?
    RadAjaxManager1.AjaxSettings.AddAjaxSetting(controlID,controlID,LoadingPAnelID)

    and perhaps
    Dim ram As RadAjaxManager = RadAjaxManager.GetCurrent(Me.Page)
    to find the ajaxmanager on the master page.
  17. Mathieu
    Mathieu avatar
    2 posts
    Member since:
    Mar 2011

    Posted 22 Jul 2011 Link to this post

    Thanks Jeff. I encountered this problem with RadControls For ASP.NET Ajax Q2 2011, and Jeff's solution works.
  18. Doug Beard
    Doug Beard avatar
    55 posts
    Member since:
    Sep 2009

    Posted 05 Jan 2012 Link to this post

    Solves the problem with the latest release still, thanks Jeff!
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017