Rad tab OnClientTabSelected event should not hit server side code
Hi,
I am using Telerik rad tabs control in my page where I am using its RadTabStrip1_TabClick
and OnClientTabSelected
both. For one tab I have to use server side code and for others I just need the OnClientTabSelected
event and it should not fire the server side code,so my question is that how I restrict the code to reach server side for those tab click where I don't need server side code.
I have used return false but it didn't 开发者_StackOverflowwork;
function onClientTabSelected(sender, args) {
//set tab value
var tabText = args.get_tab().get_index();
var tab = sender.get_selectedTab().get_text();
if (tab == 'Posts') {
ShowPostLinks();
return false;
//stop hitting server side code
}
if (tab == "Linkings") {
return true;
//go to server side
}
}
You need to use the OnClientTabSelecting event which allows cancelling. The OnClientTabSelected event is raised "after" the tab has been selected thus you cannot stop the actual selection at that time.
with most Telerik client-side events you need to do args.set_cancel(true);
instead of return false
.
They have really good documentation you can find most answers in.
精彩评论