AJAX Call (like RadTooltip) & Real Submit event.

2 posts, 0 answers
  1. Eim
    Eim avatar
    32 posts
    Member since:
    Sep 2006

    Posted 22 Feb 2012 Link to this post

    Hi,
     I need to catch the submit event in order to show a user lock layer to avoid multiple user click.
     I tried different way, submit direct event, and in the last (in the hope was the right way) this:

    In page.cs :
     protected override void OnLoad(EventArgs e) {
                base.OnLoad(e);
                ScriptManager.RegisterOnSubmitStatement(Page, Page.GetType(), "myPostbackHandler", "myPostbackHandler()");
            }
    In page.aspx :
    <script language="javascript" type="text/javascript">
            function myPostbackHandler() {
                ... code to show a layer, etc...
            }

    In every way I did,  when an ajax call occurs like  mouse over a rad:tooltip control,  
    the function myPostbackHandler or submit event is always call.

    Is there a way to distinct these DIFFERENT (ajax call, real submit) action on client side  ?

    Thanks a lot. 
  2. Tsvetina
    Admin
    Tsvetina avatar
    2481 posts

    Posted 24 Feb 2012 Link to this post

    Hello,

    I just answered your question in the support ticket you opened. I am also posting it here. If you have any further questions, please place them in the ticket, so that we avoid duplicate posts.

    Here is how you can make it work. I did not notice differences with the behavior of this approach in different RadControls versions, so it should work for you too.
    1) Attach the onsubmit event, as you suggested - through the ScriptManager
    2) Inside it, set a minimal timeout, so that the request can be processed
    3) Check if it is an ajax request through the get_isInAsyncPostBack() property of the PageRequestManager
    4) If not, show the div
    5) (optional) You could use a RadAjaxLoadingPanel and show it explicitly over the desired element in the page

    For your convenience I am attaching a sample project demonstrating this approach (I did not add the Skins dll to keep the archive as small as possible but runnable at the same time). 


    Regards,
    Tsvetina
    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