lunes, 28 de abril de 2014

AJAX - Tabs C#

I had a problem at the moment of hide a tab and after show (active) another tab. This cause me an error in javascript.

Solution

  • The first time the TabContainer is shown, ajax read the number of tabs and is all the tabs he knows.
    • In my case at the beginning show 2 tabs and hide other 2 tabs 
     
  •  In the aspx bind the method OnActiveTabChanged="TabContainerUpdate_ActiveTabChanged"
    • In the method TabContainerUpdate_ActiveTabChanged I add the condition: 
      • if (TabContainerUpdate.ActiveTabIndex != 0)
                    TabContainerUpdate.ActiveTabIndex = 1;
    • With this condition when I show another tab I assigned the new tab to the second index that ajax knows 
    • I prefer to use the ActiveTabIndex property instead of ActiveTab

 

Knowledge

  • The error is caused because at the beginning ajax only know that have 2 tabs, and when reload the page in an AutoPostback try to go to another tab with index bigger that 2

No hay comentarios:

Publicar un comentario