I got a button within an UpdatePanel. This Panel is updated every second to set background color on specified events.
Now I try to create a new tab by clicking this button.
When I put the TabContainer the new tab exists for 1 second or so. Then the TabContainer gets empty again.
Without an UpdatePanel it adds the tab of course not.
Is there any possibility to solve this problem?
Save the current state of TabContainer is not an option, cause the other opened tabs should not be reloaded.
Protected Sub OpenTab(ByVal Url As String, ByVal Title As String)
Dim tab As New AjaxControlToolkit.TabPanel()
Dim iframe As New HtmlGenericControl("iframe")
iframe.Attributes.Add("src", Url)
iframe.Attributes.Add("class", "iframetab")
tab.Controls.Add(iframe)
tab.HeaderText = Title
TabContainer1.Tabs.Add(tab)
TabContainer1.ActiveTabIndex = TabContainer1.Tabs.Count
End Sub
Protected Sub Timer1_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles Timer1.Tick
Dim Ini As New IniFile("C:\BDE.ini")
Dim CurrentButton As Button
' through all buttons
For i = 0 To 15
' Find button and cast object to button
' Only way to set attributes, sorry
CurrentButton = CType(FindControl("FehlerButton" & i), Button)
' Remove all classes
CurrentButton.Attributes.Remove("class")
' If errormessage in ini-file is bigger then zero
If Ini.GetInteger("Fehler", i, 0) > 0 Then
' Set button to error-class
CurrentButton.Attributes.Add("class", "ToolbarButtonError")
Else
' Set button to normal class
CurrentButton.Attributes.Add("class", "ToolbarButtonOk")
End If
Next i
End Sub
Protected Sub FehlerButton10_Click(ByVal sender As Object, ByVal e As EventArgs) Handles FehlerButton0.Click
OpenTab("est.aspx", "Google")
End Sub
muellerlukas
0 Points
1 Post
Tabcontainer: Add tabs by click on button in UpdatePanel
Feb 24, 2012 09:05 AM|LINK
Hi,
I got a button within an UpdatePanel. This Panel is updated every second to set background color on specified events.
Now I try to create a new tab by clicking this button.
When I put the TabContainer the new tab exists for 1 second or so. Then the TabContainer gets empty again.
Without an UpdatePanel it adds the tab of course not.
Is there any possibility to solve this problem?
Save the current state of TabContainer is not an option, cause the other opened tabs should not be reloaded.
Part out of the code:
<ContentTemplate> <asp:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="1"> </asp:TabContainer> </ContentTemplate> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Timer ID="Timer1" runat="server" Interval="1000"> </asp:Timer> <asp:Button ID="FehlerButton10" runat="server" Text="Setz" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" Width="40" /> </ContentTemplate> </asp:UpdatePanel> ------------------------------------------------------------------------------------------------------------Protected Sub OpenTab(ByVal Url As String, ByVal Title As String) Dim tab As New AjaxControlToolkit.TabPanel() Dim iframe As New HtmlGenericControl("iframe") iframe.Attributes.Add("src", Url) iframe.Attributes.Add("class", "iframetab") tab.Controls.Add(iframe) tab.HeaderText = Title TabContainer1.Tabs.Add(tab) TabContainer1.ActiveTabIndex = TabContainer1.Tabs.Count End Sub Protected Sub Timer1_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles Timer1.Tick Dim Ini As New IniFile("C:\BDE.ini") Dim CurrentButton As Button ' through all buttons For i = 0 To 15 ' Find button and cast object to button ' Only way to set attributes, sorry CurrentButton = CType(FindControl("FehlerButton" & i), Button) ' Remove all classes CurrentButton.Attributes.Remove("class") ' If errormessage in ini-file is bigger then zero If Ini.GetInteger("Fehler", i, 0) > 0 Then ' Set button to error-class CurrentButton.Attributes.Add("class", "ToolbarButtonError") Else ' Set button to normal class CurrentButton.Attributes.Add("class", "ToolbarButtonOk") End If Next i End Sub Protected Sub FehlerButton10_Click(ByVal sender As Object, ByVal e As EventArgs) Handles FehlerButton0.Click OpenTab("est.aspx", "Google") End Sub