This is a migrated thread and some comments may be shown as answers.

Perform TabClick event

1 Answer 57 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
El
Top achievements
Rank 1
El asked on 15 Nov 2010, 01:22 PM

Hello,

My question is pretty same as the following one:

http://www.telerik.com/community/forums/aspnet-ajax/tabstrip/rad-tab-click-event-not-firing-the-first-time.aspx

I followed the demo "TabStrip / Load on Demand RadPageView" and i can say that most of the code is missing so i had to combine the code from the other demoS in order to achieve what i want (please refer the code below).

However the thing is that i can't make it loads the very first pageview when tabs are created. After you click another tabpage it works as expected.

It is something similar to windows button control which has a "PerformClick" event. 

Thanks

ASP.NET (HTML)

<telerik:RadMultiPage ID="RadMultiPage1" runat="server" SelectedIndex="0"  CssClass="multiPage" />
 
<telerik:RadTabStrip OnClientTabSelecting="onTabSelecting" ID="RadTabStrip1" SelectedIndex="0" CssClass="tabStrip" runat="server" MultiPageID="RadMultiPage1" Skin="Office2007" Orientation="HorizontalBottom" />

CODE BEHIND (VB.NET)

Imports Telerik.Web.UI
 
Public Class _Default
    Inherits System.Web.UI.Page
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            AddTab("Corporate")
            AddTab("Personal")
        End If
    End Sub
 
    Private Sub AddTab(ByVal tabName As String)
        Dim tab As New RadTab
        tab.Text = tabName
        tab.Value = tabName & ".ascx"
        tab.PageViewID = tabName.Replace(" "c, "") & ".ascx"
        RadTabStrip1.Tabs.Add(tab)
    End Sub
     
    Private Sub AddPageView(ByVal pageViewID As String)
        Dim pageView As New RadPageView()
        pageView.ID = pageViewID
        RadMultiPage1.PageViews.Add(pageView)
    End Sub
 
    Protected Sub TabStrip1_TabClick(ByVal sender As Object, ByVal e As RadTabStripEventArgs) Handles RadTabStrip1.TabClick
        AddPageView(e.Tab.Value)
        e.Tab.PageView.Selected = True
    End Sub
 
    Private Sub MultiPage1_PageViewCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadMultiPageEventArgs) Handles RadMultiPage1.PageViewCreated
        Dim userControlName As String = e.PageView.ID
        Dim userControl As Control = Page.LoadControl(userControlName)
        userControl.ID = e.PageView.ID + "_userControl"
        e.PageView.Controls.Add(userControl)
    End Sub
 
End Class

1 Answer, 1 is accepted

Sort by
0
El
Top achievements
Rank 1
answered on 16 Nov 2010, 04:51 PM
I have it resolved in the meantime. I just had to manually add the pageview after i initialize the new tab page.
e.g.
' initialize the needed tab pages
AddTab("Personal Info")
AddPageView("PersonalInfo.ascx")


Later if you click this tab it does nothing because user control is already loaded into the pageview.

Thanks for reading it.
Tags
TabStrip
Asked by
El
Top achievements
Rank 1
Answers by
El
Top achievements
Rank 1
Share this question
or