RadAjaxPanel cauing full postback 1st time

46 posts, 0 answers
  1. DonKitchen
    DonKitchen avatar
    92 posts
    Member since:
    Jul 2007

    Posted 02 May 2008 Link to this post

    I'm noticing that the RadAjaxPanel control is causing a full postback when one of its child controls is fired (like a checkbox with autopostback=true).  This only happens the 1st time and all subsequent postbacks happen via AJAX.

    Any idea on why this may be happening?

    Also, when more than 1 RadAjaxPanels are on the same page, it seems that all the other update panels work fine on their 1st trigger, it's just the first request from any of them that seems to be a problem.

    These are inside a formview in a user control, if that matters.
  2. Konstantin Petkov
    Admin
    Konstantin Petkov avatar
    1911 posts

    Posted 05 May 2008 Link to this post

    Hi DonKitchen,

    Although I'm not sure what might be causing the problem, we always recommend using a RadAjaxManager/Proxy in a WebUserControls scenario:

    http://www.telerik.com/DEMOS/ASPNET/Prometheus/Ajax/Examples/Manager/UserControl/DefaultCS.aspx

    Please, give it a go and let us know if that helps.

    Sincerely yours,
    Konstantin Petkov
    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. DonKitchen
    DonKitchen avatar
    92 posts
    Member since:
    Jul 2007

    Posted 05 May 2008 Link to this post

    I took a look at the article link you provided and didn't see anything that was helpful.  Even when I added the Ajax Manager to the master page, added an Ajax Proxy to the User Control, and removed the Ajax Panel and let the Proxy handle the updates I STILL see a full page postback when the first event happens.

    So, adding the manager did not help.
  5. DonKitchen
    DonKitchen avatar
    92 posts
    Member since:
    Jul 2007

    Posted 05 May 2008 Link to this post

    I've actually reproduced the problem by putting the AjaxPanel inside a formview.  It seems that the user control has nothing to do with it.  I have prepared a sample project that I can upload if you tell me how.
  6. Konstantin Petkov
    Admin
    Konstantin Petkov avatar
    1911 posts

    Posted 06 May 2008 Link to this post

    Hi DonKitchen,

    Please, try a Manager outside the FormView as well as add the AJAX settings dynamically in this case (remove the AJAX Panel).

    Feel free to write a support ticket to send a sample project. The attachments are not allowed in the forums.

    Best wishes,
    Konstantin Petkov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  7. DonKitchen
    DonKitchen avatar
    92 posts
    Member since:
    Jul 2007

    Posted 06 May 2008 Link to this post

    I tried your suggestion about putting the manager outside the formview (which I had already) and moving the ajax settings into the code behind.  With your suggestions I don't get any Ajax functionality at all.

    I will submit a support ticket I suppose now.  I am just wondering if you were speaking from experience in your suggestion or if you were just taking a guess that your suggestion *may* work?
  8. Konstantin Petkov
    Admin
    Konstantin Petkov avatar
    1911 posts

    Posted 06 May 2008 Link to this post

    Hi DonKitchen,

    Ajaxifying data sub controls might be a bit tricky in general due to the different naming containers. You may find this article interesting for example:

    Ajaxify particlar templated GridView buttons

    We will look into your project as soon as we can.

    Greetings,
    Konstantin Petkov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  9. andrei
    andrei avatar
    7 posts
    Member since:
    Jul 2006

    Posted 07 Jul 2008 Link to this post

    Hi,

    I have the same problem with a RadAjaxPanel placed inside an ascx user control.
    First time it does a full page postback, the it's working normally.

    Are there any solutions to this issue?

    Regards
    Andrei Gosman
  10. DonKitchen
    DonKitchen avatar
    92 posts
    Member since:
    Jul 2007

    Posted 07 Jul 2008 Link to this post

    I am still having this problem.
  11. andrei
    andrei avatar
    7 posts
    Member since:
    Jul 2006

    Posted 07 Jul 2008 Link to this post

    So, no workarounds yet?

    Andrei Gosman
  12. DonKitchen
    DonKitchen avatar
    92 posts
    Member since:
    Jul 2007

    Posted 07 Jul 2008 Link to this post

    I did eventually submit a support ticket and got the following response with a sample project:

    The problem is related to the fact that the FormView in this case is not bound or bound too late for ajaxification. You can resolve this very easily if you access the FormView Controls collection in Page_Load. Here is an example:

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Dim Controls As ControlCollection = FormView1.Controls
        End Sub

    You can find modified version of your project attached.

    That didn't however work in my example because I was using a formview inside of a user control.  I can provide you with the sample project they gave me if you like.  You can email me directly at donkitchen at gmail dot com and I'll send you the sample file.
  13. Carlos
    Carlos avatar
    3 posts
    Member since:
    Nov 2007

    Posted 03 Nov 2008 Link to this post

    i'm having the same issue on the 1st post back ... is there any fix for this yet?

    thanks
  14. DonKitchen
    DonKitchen avatar
    92 posts
    Member since:
    Jul 2007

    Posted 03 Nov 2008 Link to this post

    I have not received a solution for this problem yet.
  15. Carlos
    Carlos avatar
    3 posts
    Member since:
    Nov 2007

    Posted 03 Nov 2008 Link to this post

    Good news...
    I was able to get it working is kind of nasty but works...

    The trick is calling the databind event and then adding ajax settings to the controls inside the detailsView before is rendered.



    a few things first:
    • My issue was that my user control was posting back the full page the first time it rendered.
    • I was trying this with a DetailsView control insted of a FormView... my work around should work for you too...
    • My trigger is a textbox (FirstNameTextBox) change that changes another textbox (AliasTextBox)
    what I did was:

    • Left all my code as it is (didn't remove ANYTHING, only added)
    • Declared 2 text boxes on my code behind
      TextBox txt1 = null, txt2 = null;  
    • Added a PreRender event to my control
              protected void Page_PreRender(object sender, EventArgs e) 
              { 
                  if (!IsPostBack) 
                  { 
                      RadAjaxManager manager = RadAjaxManager.GetCurrent(Page); 
                      DetailsView1.DataBind(); 
                      if ((txt1 != null) && (txt2 != null)) 
                      { 
                          manager.AjaxSettings.AddAjaxSetting(txt1, txt2); 
                      } 
                  } 
              } 
    • Added a databound event to my detailsView Control
      protected void DetailsView1_DataBound(object sender, EventArgs e) 
              { 
       
       
       
                  Control x = ((DetailsView)sender).FindControl("FirstNameTextBox"); 
                  if (x != null
                  { 
                      txt1 = (TextBox)x; 
                  } 
       
                  x = ((DetailsView)sender).FindControl("AliasTextBox"); 
                  if (x != null
                  { 
                      txt2 = (TextBox)x; 
                  } 
       
       
       
              } 

    I know this can get real nasty if you have multiple controls + triggers... but at least it works for now.......
  16. Dani
    Dani avatar
    55 posts
    Member since:
    Jan 2009

    Posted 04 Mar 2009 Link to this post

    I got the exact same trouble (full reload of the page on the first postback, then ajax works fine after).

    AND I FOUND A SOLUTION  (that is applied to my case, but it may help telerik find the bug).

    Case:
    I have a repeater and a sqldatasource.  In the itemtemplate of my repeater, I have a usercontrol, which contains an radajaxmanager (I got the same bug with the radajaxpanel, but NOT with the asp;updatepanel).  The repeater is associated with the SQLdatasource using the DataSourceID property.  There is absolutely no codebehind for this page, just a repeater, a sqldatasource, and the datasourceID to connect them together.  There is not ajax on the page containing the repeater.  The ajaxmanager is inside the usercontrol for its own content.
    <!-- NON WORKING CASE --> 
    <asp:Repeater ID="rptad" runat="server" DataSourceID="dsreview" > 
       <ItemTemplate> 
          <uc1:usercontrol containing the radajaxmanagerproxy> 
       </ItemTemplate> 
    </asp:Repeater> 
    <asp:SqlDataSource ID="dsreview" runat="server"
    ... 
    </asp:SqlDataSource> 
     

    In this case, the first call is NOT ajax enabled, the whole page refresh, but after the first call it works fine.

    I changed only this:   I removed the datasourceid, and I used this codebehind to load my repeater:
        Private Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Load 
            If Not Page.IsPostBack Then 
                rptad.DataSource = dsreview 
                rptad.DataBind() 
            End If 
        End Sub 

    Then it works.

    Note that this code is changed on the ASPX page containing the ASCX, there absolutely nothing changed in the usercontrol containing the radajaxmanager.  

    I think that this is caused by the order in which the ajaxmanager generates its code relatively to the time where the repeater is databound.  I don't know exactly when the repeater is databound when using the datasourceid property, it seems to be somewhere between the page_load and the page_prerender, but this causes the trouble. 

    Suggestion to telerik: Let the radajaxmanagerproxy do its job later during the page load to be sure to activate the ajax correctly even if we use the datasourceid property and let the page auto-charge itself.

    I got this idea when reading the solution from Carlos that inspired me.  But I can't apply its solution because my radajaxmanager is not in the same page than the one containing the control I databind.  I tried to configure the radajaxmanagerproxy programatically in the prerender of my usercontrol but it did not help.

    Then I will remove every datasourceid from every pages of my solution and load my data bound lists on the page_load events.

  17. Yuri Hinojosa
    Yuri Hinojosa avatar
    23 posts
    Member since:
    Apr 2006

    Posted 10 Mar 2009 Link to this post

    Hi,

    I have the same problem my scenario is with a FormView (with latest telerik asp.control 2008 pack)

    <FormView mode="edit" DataSourceID="DsObject">
    <EditTemplate>
          <telerik:RadAjaxPanel>
               <telerik:RadGrid>
                          ..................................
               </telerik:RadGrid>
               ......................................
               ......................................
         </telerik:RadAjaxPanel>
    </EditTemplate>
    <FormView>

    The first time that any children of the ajaxPanel perform a postback this is make as a full postback and subsequent postbacks by ajax, I confirm that is a Telerik bug because if you replace the RadAjaxPanel with an asp:UpdatePanel all work fine, the postbacks are made with ajax since the first time.

    Please Telerik we need a solution, because out-of-the-box controls as an asp:UpdatePanel work fine in this scenario and yours not.

    Regards,
    Yuri

  18. LeBear
    LeBear avatar
    233 posts
    Member since:
    May 2006

    Posted 10 Mar 2009 Link to this post

    This may not apply, but FYI...

    I also had this problem a while back.  It turned out that I was changing the action on the form via Javascript.  This caused the postback for the first Ajax call, but not for subsequent ones since the action wasn't being further changed.
  19. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 11 Mar 2009 Link to this post

    Hello Yuri,

    One thing you can try is to ajaxify the whole control, by nesting it in an AjaxPanel, rather than the editForm. If this does not help, you can open a formal support ticket, and send us the problematic code, for additional testing and debugging.

    Kind regards,
    Yavor
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  20. TonyG
    TonyG avatar
    239 posts
    Member since:
    Feb 2006

    Posted 08 May 2009 Link to this post

    I've lost a lot of hair this week and I think this thread may hold the answer, but I thought that about a dozen other threads too.

    I have a master page with a single content page which loads usercontrols dynamically.
    On a specific UC I have a radpanelbar, a radgrid, and other controls.  Each of these is in a standard asp:Panel to get a fieldset/group frame. I load the panelbar manually and it seems to work fine on events.  But the radgrid is databound to an objectdatasource.  When the SelectedItemChanged event is fired, the grid is empty and there is no selected item or value.  It's only after the event is fired and after the PreRender that the Select method is triggered on the data source.  So now my thinking based on this thread is that I need to manually bind the grid in Page_Load so that the event has some data.

    But I've been chasing at "what-if" ideas like this all week.
    What if I wrap the grid in an AjaxPanel?
    What if the asp:Panel is causing something funky?
    What if I do or don't Ajaxify the asp:panel?
    What if I move the AddAjaxSettings out of PreRender and move them somewhere else?
    What if that script to avoid the x-microsoftajax header issue is causing Telerik Response.Writes to fail?

    I just wish we had a better set of rules and better diagnostic tools.  Working with a black box like this is an ongoing exercise in futility.

    It's time to get away from the keyboard and re-think my approach to solving these problems...
  21. TonyG
    TonyG avatar
    239 posts
    Member since:
    Feb 2006

    Posted 09 May 2009 Link to this post

    Gosh I hope I'm not just blabbing but I have a follow-up to Dani's notes.  I think this will help some people.

     
    I have a RadAjaxPanel.  I load this panel manually by populating the Items collection.
    I also have a RadAjaxGrid which is databound to an ObjectDataSource.

    When the ItemClick event occurs on the panel, the required data is available in the event handler.  The sequence of events that are fired are as follows:

    Load
    ItemClick
    Select the ODS data for the grid
    PreRender

    When I click the grid, the SelectedIndexChanged is fired but the data is not available in the handler.  The sequence of events here is as follows:

    Load
    SelectedIndexChanged
    PreRender
    Select method for ODS

    Why the difference?

    Following Dani's comments I added a mygrid.DataBind() to a handler executed from Page_Load.  So the grid is bound and when the handler is invoked the data is there and everything with this now works fine.

    Looking back at this I guess there are two things going on here: First there is the matter of when the handler fires, though that's not related to the data being available for the event.  Second there's the matter of making sure data is available for the event.  Why do I need to rebind?  Why isn't it available from ViewState?

    I really hate to play guessing games.  Am I missing some fundamental rule of the ASP.NET page life cycle, or is there a bug somewhere?

    Thanks to anyone who's reading, and I hope this helps anyone looking for a solution.

  22. Jaap Goddijn
    Jaap Goddijn avatar
    3 posts
    Member since:
    Aug 2009

    Posted 27 Aug 2009 Link to this post

    Hello Telerik team,

     

    has a solution for this problem been found? I tried all suggestions in this threat, but it doesn't help me. The first postback is still a full postback.

    Thanks,
    Jaap

  23. DonKitchen
    DonKitchen avatar
    92 posts
    Member since:
    Jul 2007

    Posted 27 Aug 2009 Link to this post

    None of the solutions here fixed my problem.
  24. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 27 Aug 2009 Link to this post

    Hi guys,

    If you still experience issues as discussed in this thread, I suggest you isolate a working sample and send it enclosed to a regular support ticket. We will examine your test cases and will get back to you with our findings.

    Kind regards,
    Sebastian
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  25. TonyG
    TonyG avatar
    239 posts
    Member since:
    Feb 2006

    Posted 27 Aug 2009 Link to this post

    That's usually a reasonable request but given that so many people have posted their experience, instructions for reproducing related issues, and even code, isn't there already enough here for you to go on? I have to say, I gave up on the idea of fixing this months ago and just made my code expect the weird behavior that I was seeing. Please forgive, but we need to move on with our development and coming back to old threads to provide a reproducible case for you is very low on our list of priorities and justified allocations of time. As software developers of course we often ask for reproducible cases just like you do. But in this case how much more do you really need? Please just play with it using the information already provided here and the problems should become evident pretty quickly. If you really can't reproduce any of the issues reported here, I'll do what I can with the latest release to create an isolated code sample for you - or to report that I no longer see the issues reported.
  26. DonKitchen
    DonKitchen avatar
    92 posts
    Member since:
    Jul 2007

    Posted 27 Aug 2009 Link to this post

    Agreed, as you can see from this thread i went through the trouble of already reproducing the problem.  The sample code i got back was using some different scenario that didn't fit what I was even doing.

    I too have kind of given up on this and just learned to live with it for now.
  27. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 28 Aug 2009 Link to this post

    Hello guys,

    Unfortunately I am not able to reproduce the abnormality following the directions from your posts. I requested a sample application because I suspect that there might be something specific in your configurations which causes the postback to happen. I will be expecting your working examples in order to provide as much to-the-point answer/solution as possible.

    Best regards,
    Sebastian
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  28. ColinBowern
    ColinBowern avatar
    51 posts
    Member since:
    Aug 2012

    Posted 23 Nov 2009 Link to this post

    I managed to repro this issue with Repeater nested inside a FormView.  Using an <asp:UpdatePanel /> worked fine.  I have sent sample code in a support ticket (#260396).
  29. Jaap Goddijn
    Jaap Goddijn avatar
    3 posts
    Member since:
    Aug 2009

    Posted 24 Nov 2009 Link to this post

    Hopefully that helps the Telerik team. I'm still having this problem.
  30. ColinBowern
    ColinBowern avatar
    51 posts
    Member since:
    Aug 2012

    Posted 24 Nov 2009 Link to this post

    Here is a spike I used to get it working:

    <telerik:RadScriptManager ID="ScriptManager" runat="server" /> 
    <telerik:RadAjaxManager ID="AjaxManager" runat="server" /> 
    <asp:FormView ID="Document" runat="server" DataSourceID="DocumentDataSource" 
        DefaultMode="Edit" OnItemUpdating="Document_Updating">  
        <EditItemTemplate> 
            <h2> 
                Document Name:  
                <%# Eval("Name") %></h2>  
            <div> 
                <asp:Label runat="server" AssociatedControlID="DocumentDate" Text="Document Date:" /> 
                <telerik:RadDateInput ID="DocumentDate" runat="server" SelectedDate='<%# Bind("DocumentDate") %>' /> 
            </div> 
            <asp:Repeater ID="Sections" runat="server" DataSource='<%# Bind("Categories") %>' 
                OnDataBinding="Sections_DataBinding">  
                <ItemTemplate> 
                    <asp:Panel ID="AjaxPanel" runat="server" OnPreRender="AjaxPanel_PreRender">  
                        <contenttemplate> 
                            <asp:HiddenField runat="server" ID="Name" Value='<%# Eval("Name") %>' /> 
                            <h3> 
                                Section Name:  
                                <%# Eval("Name") %> 
                            </h3> 
                            <asp:LinkButton ID="Edit" runat="server" OnClick="Edit_Click" Text="Edit" /> 
                            <asp:LinkButton ID="Done" runat="server" Text="Done" Visible="false" OnClick="Done_Click" /> 
                            <telerik:RadListView ID="Items" runat="server" AllowMultiItemEdit="true" DataKeyNames="Name" 
                                OnNeedDataSource="Items_NeedDataSource">  
                                <LayoutTemplate> 
                                    <div> 
                                        <asp:PlaceHolder ID="itemPlaceholder" runat="server" /> 
                                    </div> 
                                </LayoutTemplate> 
                                <EditItemTemplate> 
                                    <div> 
                                        <asp:TextBox ID="Name" runat="server" Text='<%# Bind("Name") %>' /> 
                                    </div> 
                                </EditItemTemplate> 
                                <ItemTemplate> 
                                    <div> 
                                        <asp:Literal ID="Name" runat="server" Text='<%# Eval("Name") %>' /> 
                                    </div> 
                                </ItemTemplate> 
                            </telerik:RadListView> 
                        </contenttemplate> 
                    </asp:Panel> 
                </ItemTemplate> 
            </asp:Repeater> 
            <asp:Button ID="Save" runat="server" CommandName="Update" Text="Save" OnClick="Save_Click" /> 
            <asp:Button ID="Cancel" runat="server" CausesValidation="false" CommandName="Cancel" 
                Text="Cancel" /> 
        </EditItemTemplate> 
    </asp:FormView> 
    <asp:ObjectDataSource ID="DocumentDataSource" runat="server" DataObjectTypeName="Foo.Document" 
        TypeName="Foo.DataSource" SelectMethod="RetrieveDocument" UpdateMethod="UpdateDocument" /> 


    In the code behind:

    protected void Document_Updating(object sender, FormViewUpdateEventArgs e)  
    {  
        e.NewValues["Categories"] = ViewState["Sections_Data"];  
    }  
     
    protected void Save_Click(object sender, EventArgs e)  
    {  
        var save = (Control)sender;  
        var sections = (Repeater)save.Parent.FindControl("Sections");  
     
        foreach(RepeaterItem repeaterItem in sections.Items)  
        {  
            var done = (Control)repeaterItem.Controls[0].FindControl("Done");  
            if (done.Visible)  
            {  
                Done_Click(done, EventArgs.Empty);  
            }  
        }  
    }  
     
    protected void Sections_DataBinding(object sender, EventArgs e)  
    {  
        var sections = (Repeater)sender;  
        ViewState["Sections_Data"] = sections.DataSource;  
    }  
     
    protected void AjaxPanel_PreRender(object sender, EventArgs e)  
    {  
        RadAjaxManager.GetCurrent(this).AjaxSettings.AddAjaxSetting((Control)sender, (Control)sender);  
    }  
     
    protected void Items_NeedDataSource(object sender, RadListViewNeedDataSourceEventArgs e)  
    {  
        var items = (DataBoundControl)sender;  
     
        var container = (IDataItemContainer)items.Parent.Parent;  
        if (container.DataItem != null)  
        {  
            items.DataSource = ((Category)container.DataItem).Items;  
        }  
        else 
        {  
            var name = (HiddenField)items.Parent.FindControl("Name");  
            var dataSource = (List<Category>)ViewState["Sections_Data"];  
            items.DataSource = dataSource.Find(category => category.Name == name.Value).Items;  
        }  
    }  
     
    protected void Edit_Click(object sender, EventArgs e)  
    {  
        var edit = (Control)sender;  
     
        var items = (RadListView)edit.Parent.FindControl("Items");  
        foreach (RadListViewDataItem item in items.Items)  
        {  
            items.EditIndexes.Add(item.DisplayIndex);  
        }  
        items.Rebind();  
     
        var done = (Control)edit.Parent.FindControl("Done");  
        done.Visible = true;  
        edit.Visible = false;  
    }  
     
    protected void Done_Click(object sender, EventArgs e)  
    {  
        var done = (Control)sender;  
     
        var items = (RadListView)done.Parent.FindControl("Items");  
        var name = (HiddenField)done.Parent.FindControl("Name");  
     
        var dataSource = (List<Category>)ViewState["Sections_Data"];  
        items.DataSource = dataSource.Find(category => category.Name == name.Value).Items;  
        for (int i = 0; i < items.EditItems.Count; i++)  
        {  
            ((RadListViewDataItem)items.EditItems[i]).UpdateValues(((IList<DocumentItem>)items.DataSource)[i]);  
        }  
     
        items.ClearEditItems();  
        items.Rebind();  
     
        var edit = (Control)done.Parent.FindControl("Edit");  
        edit.Visible = true;  
        done.Visible = false;  
  31. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 26 Nov 2009 Link to this post

    Hello colinbo,

    We are glad that you found a solution and shared it with the rest of the Telerik community members. As a token of gratitude I updated your Telerik points.

    Best regards,
    Sebastian
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017