
Imports Telerik.Web.UI

Partial Class Default2
    Inherits System.Web.UI.Page
    Private Sub RadMenuTopItemClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadMenuEventArgs) Handles DefaultRadMenu.ItemClick

        Try

            If DefaultRadTabStrip.FindTabByText(e.Item.Text) Is Nothing Then
                AddTab(e.Item.Text)
                DefaultRadTabStrip.FindTabByText(e.Item.Text).Value = e.Item.Value
                AddPageView(DefaultRadTabStrip.FindTabByText(e.Item.Text))
                DefaultRadTabStrip.DataBind()

            Else
                DefaultRadTabStrip.FindTabByText(e.Item.Text).Selected = True
                DefaultRadTabStrip.FindTabByText(e.Item.Text).PageView.Selected = True

            End If

        Catch ex As Exception
            Throw ex
        End Try

    End Sub

    Private Sub AddTab(ByVal tabName As String)
        VisibleRadTabContent(True)
        DefaultTab.Collapsed = False

        If DefaultRadTabStrip.SelectedTab IsNot Nothing Then
            DefaultRadTabStrip.SelectedTab.Selected = False
        End If

        Dim tab As RadTab = New RadTab
        tab.Text = tabName
        tab.Selected = True
        DefaultRadTabStrip.Tabs.Add(tab)

    End Sub

    Private Sub AddPageView(ByVal tab As RadTab)
        Dim pageView As RadPageView = New RadPageView
        pageView.ID = tab.Value
        pageView.Selected = True
        pageView.Width = System.Web.UI.WebControls.Unit.Percentage(100)
        pageView.Height = System.Web.UI.WebControls.Unit.Percentage(100)
        DefaultMultiPage.PageViews.Add(pageView)
        tab.PageViewID = pageView.ID
    End Sub


    Private Sub VisibleRadTabContent(ByVal value As Boolean)
        DefaultRadTabStrip.Visible = value
        DefaultRadTabStrip.Visible = value
    End Sub

    Protected Sub DefaultMultiPage_PageViewCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadMultiPageEventArgs) Handles DefaultMultiPage.PageViewCreated
        Dim userControlName As String = e.PageView.ID + ".ascx"
        Dim userControl As Control = Page.LoadControl(userControlName)
        userControl.ID = e.PageView.ID & "_userControl"
        e.PageView.Controls.Add(userControl)
    End Sub

    Protected Sub RadAjaxManager_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs) Handles RadAjaxManager1.AjaxRequest
        Dim a = e.Argument
    End Sub
End Class

