4

I am using ajax tab container in asp.net app, having 2 tabs 1.first tab having gridview , 2. second tab having add new item form. on rowcommand click i am getting all values in second tab, on click of edit i enable all the controls to edit. During this i want to restrict user to navigate to first tab until he clicks on GotoGrid button. how to implement this? if i use

tab_name.enable=false;

it gets disabled even all the buttons and the controls. please help!

Sushant
  • 391
  • 12
  • 28

1 Answers1

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>

server code:

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 (place right after the ScriptManager control

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);
     }
}
Yuriy Rozhovetskiy
  • 22,270
  • 4
  • 37
  • 68
  • thank for reply, i have one more doubt! my container name is like this... ' ' how to get ? – Sushant Aug 20 '12 at 12:18
  • That's just a prefix. You absolutely free to use any custom prefix to register custom server controls. For example you can use `imTheMostCoolAspNetDeveloper:Accordion`. Just change `ajaxtoolkit` to `asp` in this particular case – Yuriy Rozhovetskiy Aug 20 '12 at 12:26