我在asp.net应用程序中使用ajax选项卡容器,有两个选项卡1.第一个选项卡有gridview,2。具有添加新项目表单的第二选项卡。在rowcommand上单击"我正在获取第二个选项卡中的所有值",在单击"编辑"时,我启用所有控件进行编辑。在此期间,我想限制用户导航到第一个选项卡,直到他点击GotoGrid按钮。如何实现这一点?如果我使用
tab_name.enable=false;
它甚至会禁用所有的按钮和控件。请帮忙!
<asp:HiddenField runat="server" ID="disabledPaneIndex" />
<ajaxToolkit:Accordion runat="server" ID="Accordion1" >
<Panes>
<ajaxToolkit:AccordionPane runat="server" ID="Pane1" >
<Header>
Pane 1
</Header>
<Content>
<asp:Button runat="server" ID="SwitchToPane2Button" Text="Go To Pane2" OnClick="SwitchToPane2Button_Click" />
</Content>
</ajaxToolkit:AccordionPane>
<ajaxToolkit:AccordionPane runat="server" ID="Pane2">
<Header>
Pane 2
</Header>
<Content>
<asp:Button runat="server" ID="SwitchBackButton" Text="Go Back" OnClick="SwitchBackButton_Click" />
</Content>
</ajaxToolkit:AccordionPane>
</Panes>
</ajaxToolkit:Accordion>
服务器代码:
protected void SwitchToPane2Button_Click(object sender, EventArgs e)
{
Accordion1.SelectedIndex = 1;
disabledPaneIndex.Value = "0";
}
protected void SwitchBackButton_Click(object sender, EventArgs e)
{
disabledPaneIndex.Value = string.Empty;
Accordion1.SelectedIndex = 0;
}
JavaScript(位于ScriptManager
控件的正后方
function pageLoad() {
var accordion = $find("<%= Accordion1.ClientID %>_AccordionExtender");
accordion.remove_selectedIndexChanging(selectedIndexChanging);
accordion.add_selectedIndexChanging(selectedIndexChanging);
}
function selectedIndexChanging(sender, args) {
var disabledIndexValue = parseInt($get("<%= disabledPaneIndex.ClientID %>").value);
if (!isNaN(disabledIndexValue) && args.get_selectedIndex() === disabledIndexValue) {
args.set_cancel(true);
}
}