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

RaisePostBackEvent not always firing

5 Answers 199 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Martin Roussel
Top achievements
Rank 1
Martin Roussel asked on 25 Sep 2012, 12:27 PM
Hi, I have a very annoying problem with my app and cant find any similar topic. I have a Page with a RadAjaxPanel containing 2 RadPanes (1 for Menu and 1 for Page content). The Page also have a second RadAjaxPanel containing some RadComboBoxes. On some predefined conditions, selecting an item in the mentionned RadComboBoxes should trigger a postback refresh on the Page content pane mentioned. Everything works but approx 10% of the time, the postback seems not be firing. When it happens I simply select something else in my RadComboBoxes and then it works. Cant find any pattern to replicate as it seems totally random.

Panel with comboboxes
<telerik:RadAjaxPanel ID="RadAjaxPanel2" runat="server">
           
               <div class="EnterpriseNodes1">
                    <telerik:RadComboBox ID="RadComboBox1" runat="server" Skin="WebBlue" MarkFirstMatch="true" Visible="false" AllowCustomText="true" Filter="StartsWith" CssClass="combo1" NoWrap="True" OnItemDataBound="RadComboBox1_ItemDataBound" AutoPostBack="True" OnSelectedIndexChanged="RadComboBox1_OnSelectedIndexChanged" OnClientDropDownOpened="ShowEmptyMessage" OnClientDropDownClosed="HideEmptyMessage" >
                    </telerik:RadComboBox>
                    <br />
                    <telerik:RadComboBox ID="RadComboBox2" runat="server" Skin="WebBlue" MarkFirstMatch="true" Visible="false" AllowCustomText="true" Filter="StartsWith" CssClass="combo2" NoWrap="True" OnItemDataBound="RadComboBox2_ItemDataBound" AutoPostBack="True" OnSelectedIndexChanged="RadComboBox2_OnSelectedIndexChanged" OnClientDropDownOpened="ShowEmptyMessage" OnClientDropDownClosed="HideEmptyMessage">
                    </telerik:RadComboBox>
                    <br />
                    <telerik:RadComboBox ID="RadComboBox3" runat="server" Skin="WebBlue" MarkFirstMatch="true" Visible="false" AllowCustomText="true" Filter="StartsWith" CssClass="combo3" NoWrap="True" OnItemDataBound="RadComboBox3_ItemDataBound" AutoPostBack="True" OnSelectedIndexChanged="RadComboBox3_OnSelectedIndexChanged" OnClientDropDownOpened="ShowEmptyMessage" OnClientDropDownClosed="HideEmptyMessage">
                    </telerik:RadComboBox>
                 </div>
 </telerik:RadAjaxPanel>

Panel with 2 panes
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" Height="100%" Width="100%">
          
            <telerik:RadSplitter ID="RadSplitter1" PanesBorderSize="0" BorderSize="0" runat="server" Orientation="Vertical" Width="99%" Height="109%">
                 
                <telerik:RadPane ID="RadPane1" runat="server" CssClass="MenuPane" MinWidth="220" Width="220px" Height="100%">
 
                    <telerik:RadSplitter ID="RadSplitter2" PanesBorderSize="0" BorderSize="0"  runat="server" ResizeWithParentPane="false" Orientation="Horizontal" Width="100%" Height="100%">
                 
                        <telerik:RadPane ID="RadPane3" runat="server" CssClass="MenuPane2" Width="100%" Height="50%">
              
                             <telerik:RadMenu ID="RadMenu2" runat="server" Visible="false" CssClass="menu3" OnItemClick="RadMenu_ItemClick" EnableImageSprites="true" BorderStyle="None" Flow="Vertical">
                
                             </telerik:RadMenu>
 
                         </telerik:RadPane>
 
 
                         <telerik:RadPane ID="RadPane4" runat="server" CssClass="MenuPane2" Width="100%" Height="50%">
 
                        <telerik:RadMenu ID="RadMenu3" runat="server" Visible="false" CssClass="menu3" OnItemClick="RadMenu_ItemClick" EnableImageSprites="true" BorderStyle="None" Flow="Vertical">
                              
                                 </telerik:RadMenu>
 
                          </telerik:RadPane>
 
                       </telerik:RadSplitter>
                 
                </telerik:RadPane>
 
              
                <telerik:RadPane ID="RadPane2" runat="server" CssClass="ContentPane" ContentUrl="Test.aspx">
                </telerik:RadPane>
                
            </telerik:RadSplitter>
        </telerik:RadAjaxPanel>


The function doing the magic is this one:
public void RefreshPanel(ref RadAjaxPanel rapPanel, ref RadPane rpPane, string strUrl, string strQuerystring)
        {
            rpPane.ContentUrl = strUrl + strQuerystring;
 
            WriteLog(rpPane.ContentUrl); //logging to check if code is called with right parameters
 
            rapPanel.RaisePostBackEvent(null);
        }

Everytime I check my log file (when refresh seemed to not occur), RaisePostBackEvent was called and ContentUrl of rpPane has the right value.

Is there a better way to do this, or any other property of rpPane/rapPanel I can check to find what could be wrong? Please help, this is killing me.

UPDATE: Can it be because im running the demo of the control (and sometimes get the "Thank you for using the Trial Version of RadControls for ASP.NET AJAX ..." message) and affect the post backs?

TIA

5 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 28 Sep 2012, 10:40 AM
Hi Martin,

The most probable reason for the presented issue is a client error that appear during the request which causes its termination. Could you please use some of the browser's dev tools and inspect the request to see if any errors appear.
Also in case you are updating controls added in a RadAjaxPanel from control updated by another AjaxPanel you should follow the logic described below:
http://www.telerik.com/help/aspnet-ajax/ajax-interaction-between-panels.html

I hope this helps.

Greetings,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Martin Roussel
Top achievements
Rank 1
answered on 28 Sep 2012, 12:18 PM
Thanks Maria,

Ive not seen any error (in FF Error Console) so far, but I'll check more and with other browsers.

I tried what your link documentation is suggesting and it seems to solve it so far (fingers crossed). However, I got some questions regarding the example demonstrated:

1-It says "so it is always recommended using RadAjaxManager when an update to external controls is needed." But the example provided is NOT using the Manager. Is there a safer way to do this that is not shown (with the Manager)? What is it?

2-Here's my version (that ive managed to make work) but not sure if doing it the right way:
public void RefreshPanel(ref RadAjaxPanel rapPanelFrom, ref RadAjaxPanel rapPanel, ref RadPane rpPane, string strUrl, string strQuerystring)
        {
             
 
            rpPane.ContentUrl = strUrl + strQuerystring; //seems to be lost in page_PreRender
            
            WriteLog(rpPane.ContentUrl);
            
            //rapPanel.RaisePostBackEvent(null);
            rapPanelFrom.ResponseScripts.Add(String.Format("$find('{0}').ajaxRequest();", rapPanel.ClientID));
        }

protected void Page_PreRender(object sender, EventArgs e)
    {
        if (RadAjaxPanel1.IsAjaxRequest)
        {
            if (Session["ContentUrl"] != null)
            {
                RadPane2.ContentUrl = Session["ContentUrl"].ToString();
                Session.Remove("ContentUrl");
            }
        }
    }

It seems that I need to set a session variable before calling RefreshPanel() containing the wanted ContentUrl (else I lose it in the _PreRender)..Is there a cleaner way to pass the parameter? Like adding it somehow in the ResponseScript and accessing it in the _PreRender.

TIA



0
Maria Ilieva
Telerik team
answered on 03 Oct 2012, 08:25 AM
Hello Martin,

The updated approach you have implemented is totally correct and should properly work for this scenario.

As for the RadAjaxManager option, possible approach would be to replace the RadAjaxPanels on the page with regular asp Panel control and add a settings in which these two panels update each other. Similar to this:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
        <AjaxSettings
            <telerik:AjaxSetting AjaxControlID="Panel2"
                <UpdatedControls
                    <telerik:AjaxUpdatedControl ControlID="Panel2"/> 
                    <telerik:AjaxUpdatedControl ControlID="Panel1"/> 
                    </telerik:AjaxUpdatedControl
                </UpdatedControls
            </telerik:AjaxSetting
            <telerik:AjaxSetting AjaxControlID="Panel1"
                <UpdatedControls
                    <telerik:AjaxUpdatedControl ControlID="Panel1"/> 
                    <telerik:AjaxUpdatedControl ControlID="Panel2"/> 
                </UpdatedControls
            </telerik:AjaxSetting
        </AjaxSettings
    </telerik:RadAjaxManager
    
    
    
<asp:Panel ID="Panel2" runat="server"
               <div class="EnterpriseNodes1"
                    
                    
                 </div
 </asp:Panel
    
<asp:Panel ID="Panel1" runat="server"
            <telerik:RadSplitter ID="RadSplitter1" PanesBorderSize="0" BorderSize="0" runat="server" Orientation="Vertical" Width="99%" Height="109%"
                    
                    
                    
                    
            </telerik:RadSplitter
 </asp:Panel>


Kind regards,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Martin Roussel
Top achievements
Rank 1
answered on 05 Oct 2012, 01:17 PM
Maria,

Unfortunately, im still experiencing random refreshing problems with the solution provided from the doc (sometimes, the content RadAjaxPanel doesnt get refreshed even if "ResponseScripts" is set up correctly.) I have also a third RadAjaxPanel on my page (that I didnt mentioned earlier...and also get refreshed based on combobox selection) that still use my old "RaisePostBackEvent" method ...but this one has refreshed correctly, when problem occurs. Now im wondering if that old method was safer? :(

I noticed that most of the time it fails, it is at the first combobox selection change (the first time after I launch the app in debug mode). Seem like all other selection changes refresh the pane as expected.

I tried the Manager method with regular panels as suggested but ran into multiple problems: Pane get updated everytime I select something in the comboboxes (there are conditions if we update the pane or not) and also regular ASP panels seem to have trouble to set their height to 100%.
0
Maria Ilieva
Telerik team
answered on 10 Oct 2012, 01:47 PM
Hello Martin,

From the last post it is rather difficult for me to correctly understand the randomly updates problem you are still facing and also the difficulty you are experiencing with the RadAjaxManager settings. It will be best if you could open a regular support ticket and send us sample runnable version of your application which demonstrates the problematic beahvior you are facing. Thus we will be able to debug it locally and do our best to provide the most suitable approach for your case.

Kind regards,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Ajax
Asked by
Martin Roussel
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Martin Roussel
Top achievements
Rank 1
Share this question
or