Error when mixing RadAjaxManager and asp:UpdatePanel using asp:PostBackTrigger

12 posts, 0 answers
  1. Zoe
    Zoe avatar
    6 posts
    Member since:
    Aug 2007

    Posted 06 Jun 2008 Link to this post

    Hi,

    We have a large web application project which we want to start implementing RadAjaxManager in, due to advantages it has over standard UpdatePanels. Unfortunately we have come across a problem which prevents gradual integration, which is that if the RadAjaxManager is set to update a usercontrol (or a control containing the usercontrol) which itself contains a normal asp UpdatePanel with a PostBackTrigger defined (as opposed to the usual AsyncPostBackTrigger) then you get an error when loading the page Unable to cast object of type 'System.Web.UI.PostBackTrigger' to type 'System.Web.UI.AsyncPostBackTrigger'. It looks like something in the RadAjaxManager might be assuming that all triggers are of the latter type?

    I have replicated this problem in a small project (with very contrived examples but they show the error). We can work around the error now we know what the cause is, but it does mean updating quite a lot of pages/controls where PostBackTrigger is already used, whereas we had hoped to avoid a mass change all at once. The application is very large and quite complex so we may just abandon using RadAjaxManager for now, which would be a shame.

    I'm posting this because the error message was not found by google (frustrating - if anyone else happens to encounter this they'll hopefully find this post now) and there's a chance someone might have a bright idea or tell me the obvious thing that's wrong, or Telerik might fix it/document it :)

    Controls/UpdatePanelControl.ascx snippet
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="False" UpdateMode="Conditional"
        <ContentTemplate> 
            <div class="count"
                <asp:Label ID="lblCount" runat="server" Text="0"></asp:Label> 
                <asp:Button ID="btnAdd" runat="server" OnClick="btnAdd_Click" Text="Add" /> 
            </div> 
        </ContentTemplate> 
        <Triggers> 
            <asp:PostBackTrigger ControlID="btnAdd" /> 
        </Triggers> 
    </asp:UpdatePanel> 

    Controls/UpdatePanelControl.ascx.cs click event handler
            protected void btnAdd_Click(object sender, EventArgs e) 
            { 
                int count; 
                if (!int.TryParse(lblCount.Text, out count)) 
                    count = 1; 
     
                lblCount.Text = (count + 1).ToString(); 
            } 

    RADAjaxManagerError.aspx snippet
            <telerik:RadScriptManager ID="ScriptManagerRad" runat="server"></telerik:RadScriptManager> 
            <h1>Header that should be static</h1> 
            <asp:Button ID="btnPanel" runat="server" Text="Hide Panel" onclick="btnPanel_Click" /> 
            <asp:Panel ID="pnlShowHide" runat="server"
                <ctl:updatepanelcontrol runat="server" ID="ctlUpdate" /> 
            </asp:Panel> 
            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
                <AjaxSettings> 
                    <telerik:AjaxSetting AjaxControlID="btnPanel"
                        <UpdatedControls> 
                            <telerik:AjaxUpdatedControl ControlID="btnPanel" /> 
                            <telerik:AjaxUpdatedControl ControlID="pnlShowHide" /> 
                        </UpdatedControls> 
                    </telerik:AjaxSetting> 
                </AjaxSettings> 
            </telerik:RadAjaxManager> 

    RADAjaxManagerError.aspx.cs click event handler
            protected void btnPanel_Click(object sender, EventArgs e) 
            { 
                btnPanel.Text = btnPanel.Text == "Hide Panel" ? "Show Panel" : "Hide Panel"
                pnlShowHide.Visible = !pnlShowHide.Visible; 
            } 
  2. Pavel
    Admin
    Pavel avatar
    904 posts

    Posted 09 Jun 2008 Link to this post

    Hi Zoe,

    We will need to investigate further whether the functionality of the RadAjaxManager can be changed so that the error is not received in such scenarios. For the time being we can advise you to use RadAjaxManager only and remove any UpdatePanels. This will ensure that no such errors occur.

    Kind regards,
    Pavel
    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. Chris
    Chris avatar
    171 posts
    Member since:
    Oct 2006

    Posted 10 Jun 2008 Link to this post

    Hi,

    I have the same issue as Zoe. 

    Zoe, how do you do your work around?  I am interested to know.

    Chris
  5. bhav2007
    bhav2007 avatar
    5 posts
    Member since:
    Jan 2007

    Posted 12 Jun 2008 Link to this post

    I'm also experiencing this problem. The problem with the workaround which Pavel suggested is that the RadAjaxManager does not allow you to specify that a specific control should cause a real post back rather than an ajax request. We need a certain button to cause a real post back because our form contains a RadUpload control, and files cannot be uploaded using an ajax request.

    Workarounds are suggested in the RadUpload documentation, but they are undesirable in that they require the use of javascript, which we have not used in any other place on our site, and with which I am not familiar.

    I submitted a RadGrid bug a few days ago with a very similiar exception (see support ticket 140452). The Telerik representation said that the problem was related to LINQ. May I suggest that this problem may be LINQ related as well?
  6. bhav2007
    bhav2007 avatar
    5 posts
    Member since:
    Jan 2007

    Posted 12 Jun 2008 Link to this post

    Correction: After looking at the RadControls source it appears that the problem is not LINQ related. At line 568 in Ajax/RadAjaxControl.cs there is a foreach loop which attempts to cast each of the objects in the UpdatePanel.Triggers list to an AsyncPostBackTrigger.
  7. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 13 Jun 2008 Link to this post

    Hi guys,

    We fixed this problem and the fix will be available in the upcoming service pack next week. You can request latest build via support ticket.

    Best wishes,
    Vlad
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  8. Zoe
    Zoe avatar
    6 posts
    Member since:
    Aug 2007

    Posted 17 Jun 2008 Link to this post

    Chris - we didn't have a workaround, except to do what I wanted to use RadAjaxManager for with normal ASP UpdatePanels instead (fortunately it wasn't a complicated scenario).

    Vlad - thanks for letting us know about a fix being released - knowing that means we'll revisit using RadAjaxManager at some point in the near future.

    Zoë
  9. Fiona
    Fiona avatar
    2 posts
    Member since:
    Dec 2007

    Posted 25 Jun 2008 Link to this post

    Is this service pack available yet please?

    I have experienced the same problem with a RadUpload control inside an UpdatePanel using PostBackTrigger which worked fine until a RadAjaxManager was introduced on the master page. Now when my page loads I get the same exception thrown.
  10. Konstantin Petkov
    Admin
    Konstantin Petkov avatar
    1911 posts

    Posted 25 Jun 2008 Link to this post

    Hello Fiona,

    Yes, the problem has been officially addressed in the Service Pack 2 of RadControls for ASP.NET AJAX Q1 2008. The official version is labeled 2008.1.619.

    Greetings,
    Konstantin Petkov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  11. Fiona
    Fiona avatar
    2 posts
    Member since:
    Dec 2007

    Posted 25 Jun 2008 Link to this post

    Thanks I have found it now and downloaded it.
  12. Baal
    Baal avatar
    47 posts
    Member since:
    Mar 2008

    Posted 08 Aug 2008 Link to this post

    I am using the 2008 Q2 build and am still having the same problem. Is the problem fixed only in Q1 updated build? It should be included in the Q2 build as well, shouldn't it?
  13. Konstantin Petkov
    Admin
    Konstantin Petkov avatar
    1911 posts

    Posted 11 Aug 2008 Link to this post

    Hello Baal,

    Yes, the fix is included in next versions as well. I just tried the scenario posted by Zoe in this thread but it functions properly on my end.

    Do you get the error with the same code posted in this thread or is this a different issue? Please isolate the problem in a sample scenario which we can run locally and replicate the problem. We will get back to you with resolution.

    All the best,
    Konstantin Petkov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017