Unable to Stop post backing on RadTab change

2 posts, 1 answers
  1. Srinath
    Srinath avatar
    23 posts
    Member since:
    May 2008

    Posted 02 Jun 2009 Link to this post

    I am unable to validate JavaScript Events before navingating to server side click event.

    For instance I have 5 Tabs , I need to Check a condition client side, before posting back. If the condition is not satisfied I need to avoid post back of the page. But I am unable to validate such Javascript method.

    I tried using  the below code on client side, but it not stopping the postback
    ============================================================

    function

     

    OnClientTabSelecting(sender,args)

     

    {

     

    var newTabValue = args.get_tab().get_value();

     

     

    var oldTabValue = sender.get_selectedTab().get_value();

     

    document.getElementById(

    '<%=hdnCurrentTabid.ClientID%>').value=oldTabValue;

     

     

     

    return false;
    }

    ===============================================================
    Please Help me out soon on this. I really struck up wit this :(.



    --Srinath
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 02 Jun 2009 Link to this post

    Hi Srinath,

    You can cancel the PostBack by using args.set_cancel(true) method.

    JavaScript:
     
    <script type="text/javascript"
    function OnClientTabSelecting(sender,args) 
        var newTabValue = args.get_tab().get_value(); 
        var oldTabValue = sender.get_selectedTab().get_value(); 
        if(oldTabValue == 'Value 2'// Condition 
        { 
            args.set_cancel(true); 
        } 
    </script> 

    Thanks,
    Shinu.
Back to Top