我有代码:
$("[id$='tab_TabContainer1_TabPanel1']").click(function (event) {
event.preventDefault(); //doesn't work apparently but doesn't error anywhere.
var container = $find('TabContainer1'); //select the container holding the tabs to set the active tab
if (Page_IsValid) {
container.set_activeTabIndex(1); //go ahead to next tab
}
else {
container.set_activeTabIndex(0); //Remain on this tab
}
});
我可以让相同的代码发出警报,但我只是不想能够前进到下一个选项卡,除非页面已经过验证。那有意义吗?
容器和选项卡在 asp.net 中定义为:
<ajaxToolkit:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="2" EnableViewState="False">
<ajaxToolkit:TabPanel ID="TabPanel1" runat="server" HeaderText="TabPanel1" >