我有代码:
$("[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" >