4

我在 asp.net 应用程序中使用 ajax 选项卡容器,有 2 个选项卡 1.第一个选项卡有 gridview ,2.第二个选项卡有添加新项目表单。在行命令上单击我在第二个选项卡中获取所有值,在单击编辑时我启用所有控件进行编辑。在此期间,我想限制用户导航到第一个选项卡,直到他单击GotoGrid按钮。如何实施?如果我使用

tab_name.enable=false;

它甚至被禁用所有按钮和控件。请帮忙!

4

1 回答 1

1
<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);
     }
}
于 2012-08-20T07:12:01.760 回答