使用JQuery onclick调用防止Ajax TabPanel的默认行为?

时间:2012-10-03 18:18:47

标签: jquery asp.net ajax default tabpanel

我有代码:

    $("[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" >

0 个答案:

没有答案