Tabs behavior

Just wonder how this is possible to happen with the Microsoft WebControls
I have this code to generate some Tabs.

For each Subdir in dir.getdirectories
Dim Tab as new Microsoft.web.ui.Webcontrols.Tab()
Tab.Text = Subdir.Name
MyTabstrip.Items.add(Tab)

'Place where I add my controls and events

next

In this loop I have also created some controls.
Well everything worked perfectly until I discovered very quickly that my code added more Tabs everytime a Postback happened.

Weird, because for my controls, I have to recreate them everytime, Postback or not Postback.
Is it because they are part of IE or some other htc ?

So now the code works fine adding the test in Blue:

For each SubDir in Dir.Getdirectories

if not IsPostback then

Dim Tab as new Microsoft.web.Ui.Webcontrols.Tab()
Tab.Text=Subdir.Name

MyTabstrip.Items.Add(Tab)
End if
'Place where I add my controls and content
Next

No Comments