How to know server response in ResponseEnd method of a RadAjaxManager

2 posts, 0 answers
  1. Kranti
    Kranti avatar
    3 posts
    Member since:
    Dec 2009

    Posted 24 Jan 2012 Link to this post

    Hi,

    Im using Rad ajax manager, RadAjaxLoadingPanel in my webform.

    I have two panels in my form, Panel1 is having Create account controls and  another Panel2 is for Thank you notes.

    When user created an account successfully i need to hide Panel 1 and show Panel 2.
    Im using ResponseEnd method to do make visible/hide using Javascript below method.

     function ResponseEnd(sender, arguments) {
      //hide the loading panel and clean up the global variables 
                   
                    if (currentLoadingPanel != null) {
                        currentLoadingPanel.hide(currentUpdatedControl);
                    }
                   ShowTY();
                   currentUpdatedControl = null;
                   currentLoadingPanel = null;
                   
    }

      function ShowTY(){
                       document.getElementById('<%= Panelty.ClientID %>').style.visibility = "visible";
                        document.getElementById('<%= Panelty.ClientID %>').style.display = "block";
                        document.getElementById('<%= Panelsu.ClientID %>').style.visibility = "false";
                        document.getElementById('<%= Panelsu.ClientID %>').style.display = "none";
      }

    If user already exist or any db server error i need show Panel1 display error message in a Label 
    For this I need to write a condition to check whether server response succeeded or not in the above method.

    Please let me know how i can know the server response or how i can handle this issue.....
    Please reply soon

    Thanks

      

  2. Andrey
    Admin
    Andrey avatar
    836 posts

    Posted 26 Jan 2012 Link to this post

    Hi,

    You could try slightly different approach. Instead of checking whether the response has succeeded or not you could place one HiddenField control on your page and assign its value with some default error message, the on every successful postback you should replace the text with something different. Then you could check on the client what is the value of this HiddenField and based on this value you will change the visibility of the panel.

    For example on successful postback you could set the value to "Normal" or "Expected" and if the user exists or some DB error is thrown you could set the value to "Abnormal" or "UnExpected". Then you could check if the value is "UnExpected" for example you could hide the panel with similar to this code:

    function ShowHide(panelId){
    var panel =document.getElementById(panelId);
    if(panel.style.display == 'none'){
    panel.style.display = 'block;
    }
    else
    panel.style.display = 'none;
    }

    Give this approach a try and check whether this is the desired behavior.

    All the best,
    Andrey
    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
Back to Top