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

Unable to Stop post backing on RadTab change

1 Answer 76 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Srinath
Top achievements
Rank 1
Srinath asked on 02 Jun 2009, 12:35 PM
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

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 02 Jun 2009, 01:35 PM
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.
Tags
TabStrip
Asked by
Srinath
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or