RadAjaxPanel disabling Master Page Events?

9 posts, 0 answers
  1. Boris
    Boris avatar
    275 posts
    Member since:
    Oct 2012

    Posted 11 Aug 2014 Link to this post

    I have an odd problem and I don't know if it's Telerik-related or something more basic.  For the most part everything is working perfectly, with this one exception.

    In my Asp.Net web app (Dot Net 4.0/C#) I have a page with a master page.  

    The master page's main purpose is to provide a variety of navigational links across the top of the page.  This includes a bound Asp:Repeater control that contains a set of LinkButtons, defined as follows:
    <asp:Repeater ID="MyRepeater" runat="server" >
       <HeaderTemplate>                                      
          <asp:LinkButton ID="btn1" runat="server" OnClick="btn_Click" Tooltip='-1' Text='Display All Teams' CausesValidation="false" Visible="false" ></asp:LinkButton> 
       </HeaderTemplate>
       <ItemTemplate >
          <asp:LinkButton ID="btn1" runat="server" OnClick="btn_Click" Tooltip='<%# Bind("Id") %>' Text='<%# Bind("Desc") %>' CausesValidation="false" ></asp:LinkButton>
       </ItemTemplate>
    </asp:Repeater>


    Most of the page itself is contained in a RadAjaxPanel.  Within it is a RadComboBox set up to do postbacks.  The combox box always triggers the page_load event in the Master Page.

    The problem is this:  After the RadComboBox is used at least once, the btn_Click event of the repeater buttons is disabled.  It does not seem to matter whether or not the repeater is refreshed.  The buttons are always disabled.  The only way to reactivate them is to hit the browser refresh button and completely reload the page.

    Suggestions?   Am I missing something basic?
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 12 Aug 2014 in reply to Boris Link to this post

    Hi Boris,

    Unfortunately I couldn't replicate the issue at my end. Please have a look into the sample code snippet which works fine at my end. Please provide a sample code snippet or try to replicate the issue in the provided code for further help.

    Master Page:
    <asp:Repeater ID="MyRepeater" runat="server" DataSourceID="SqlDataSource1">
        <HeaderTemplate>
            <asp:LinkButton ID="btn1" runat="server" x ToolTip='-1' Text='Display All Teams' OnClick="btn_Click" CausesValidation="false" Visible="false"></asp:LinkButton>
        </HeaderTemplate>
        <ItemTemplate>
            <asp:LinkButton ID="btn1" runat="server" OnClick="btn_Click" CausesValidation="false" ToolTip='<%# Bind("CountryId") %>' Text='<%# Bind("CountryName") %>'></asp:LinkButton>
        </ItemTemplate>
    </asp:Repeater>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ConnectionStrings:ConnectionString %>" SelectCommand="SELECT [CountryId], [CountryName] FROM [Country]"></asp:SqlDataSource>

    Content Page ASPX:
    <telerik:RadAjaxPanel ID="rajaxpnlComboItems" runat="server">
        <telerik:RadComboBox ID="rcboddlItems" runat="server" AutoPostBack="true">
            <Items>
            <telerik:RadComboBoxItem Text="Item1" />
            <telerik:RadComboBoxItem Text="Item2" />
            <telerik:RadComboBoxItem Text="Item3" />
            </Items>
        </telerik:RadComboBox>
    </telerik:RadAjaxPanel>

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Boris
    Boris avatar
    275 posts
    Member since:
    Oct 2012

    Posted 12 Aug 2014 in reply to Shinu Link to this post

    I'm not at all clear what just happened but I'll try to summarize.  I think I've fixed it.

    First of all I could not get the problem to occur with Shinu's example, either by using a SqlDataSource (which I don't normally use) or our own Linq data layer (patterned on Telerik examples.)

    I should mention that I normally develop with Chrome.  I should have done this earlier but I tried running the same tests on my problem page using IE and FireFox.  This time I got a screen crash.  

    Server Error in '/' Application.
    Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.ArgumentException: Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.


    I've not encountered this before.  I am not familiar with this but on a hunch I removed the !IsPostBack filter on the call that populates the repeater.  The repeater is refreshed every time there's a post-back.   I could have sworn I'd tried this before but in any case, this time it worked.  No more crashes.  

    (Perhaps the problem is that the problem dropdown, when doing a post-back, repopulates other dropdown controls?)


  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 12 Aug 2014 in reply to Boris Link to this post

    Hi Boris,

    With the provided information I couldn't replicate the issue at my end. Basically the problem you are facing is caused of abnormal change of the ViewState during postbacks. Event validation checks the incoming values in a POST to ensure the values are recognized. In other words, saved hash values in the __EVENTVALIDATION are different from these send through POST method.

    One of the possible, solution is to disable event validation.

    <@Page ... validateRequest="false" enableEventValidation="false" />

    Another suggestion is that check if you are calling DataBind() or Rebind() method in the PageLoad event. If so, try adding these methods within some condition check based on your scenario.

    Thanks,
    Shinu
  6. Boris
    Boris avatar
    275 posts
    Member since:
    Oct 2012

    Posted 13 Aug 2014 in reply to Shinu Link to this post

    First of all I must admit that my last post is not completely accurate.  As I said, the repeater is now refreshed during every page_load.  

    (Is this what you were referring to in your last post?)

    This modification fixed the problem when running in FireFox or Internet Explorer.  It still persists in Chrome.  

    I tried adding the enableEventValidation="false" statement but without effect.
  7. Boris
    Boris avatar
    275 posts
    Member since:
    Oct 2012

    Posted 13 Aug 2014 in reply to Boris Link to this post

    P.S.  Just as a hunch, I also tried setting the repeater to EnableViewState="false" ViewStateMode="Disabled".  

    No effect at all.
  8. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 15 Aug 2014 Link to this post

    Hello Boris,

    Please check the following article that describes common issues that are observed when controls on the page are Ajax-ified.

    In case you do not find a solution in the article would you share your full markup with the related code-behind? This way we would have better understanding of the scenario that you have. It would also allow everyone who would like to help to investigate the code and look for the cause of the issue.


    Regards,
    Viktor Tachev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  9. Boris
    Boris avatar
    275 posts
    Member since:
    Oct 2012

    Posted 15 Aug 2014 in reply to Viktor Tachev Link to this post

    So far, no good.  I don't see anything in that list that would appear to directly relate to my problem.

    Just thought of something.  As I said, most of the page is enclosed in a RadAjaxPanel. The RadComboBox causing the post-back is inside the panel.  So why is this triggering the Page_Load event of the Master Page (which loads the repeater, which is outside the RadAjaxPanel)?

    (As far as sharing code is concerned, I'm willing to share the code with the Telerik staff.  I don't believe my employer would want me to post whole pages in a public forum.)
  10. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 19 Aug 2014 Link to this post

    Hello Boris,

    Please note that having Ajax on the page does not change the page life cycle. The same page events are still executed even on partial updates.

    This said, would you try to disable Ajax in the application and see if the behavior changes? In case the issue persists, it is likely not Ajax related.

    Also, would you try to use RadAjaxManager to Ajax-enable the controls as it is designed to be used in more complex scenarios. When using RadAjaxManager  note that Ajax-ifying hidden controls is not supported. In such scenarios you should place the hidden control in a container that is always visible (e.g. Panel) and add that container to the AjaxSettings of RadAjaxManager.

    If you prefer not to share your code publicly you could send a formal support ticket and attach your project there.

    Regards,
    Viktor Tachev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017