Welcome Guest Search | Active Topics | Sign In | Register

TabStrip - MasterPage Events Options
Jim Zuber
Posted: Friday, July 6, 2007 5:07:06 PM
Rank: Member
Groups: Member

Joined: 6/21/2007
Posts: 12
I have defined a TabStrip on Masterpage and would like to be able to respond to clicks on the tabstrip from within my content pages. If I put the following event handler in the Masterpages code behind file, I can see the events:

Private Sub TabStrip1_ItemClick(ByVal sender As System.Object, ByVal e As EO.Web.NavigationItemEventArgs) Handles TabStrip1.ItemClick
Label1.Text = e.NavigationItem.ItemID
End Sub

I was able to successfully change the SelectedIndex of the TabStrip on the masterpage with the following code...

Protected Sub Page_LoadComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LoadComplete
If IsPostBack = False Then
'*** Set Tab to correct default for this Page ***
Dim menuTabStrip As EO.Web.TabStrip
menuTabStrip = CType(Master.FindControl("TabStrip1"), EO.Web.TabStrip)
menuTabStrip.SelectedIndex = 3
End If
End Sub


But, I am having a hard time figuring out how to extend the syntax above to work with the event handler on the content page. Your help would be greatly appreciated!

Jim
eo_support
Posted: Friday, July 6, 2007 10:22:08 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
hi, Jim

Thanks for posting your question here.
So, you mean you put the TabStrp on Masterpage, but want to have the handler in content page? This might be a little bit tough. I will try this and see I can come up with some solution. I will post it out if I have.

Thanks.
Jim Zuber
Posted: Saturday, July 7, 2007 5:53:28 AM
Rank: Member
Groups: Member

Joined: 6/21/2007
Posts: 12
Yes, that is exactly what I am trying to do.

Jim
Jim Zuber
Posted: Saturday, July 7, 2007 11:18:01 AM
Rank: Member
Groups: Member

Joined: 6/21/2007
Posts: 12
Although not as clean, it just dawned on me that I could put multiple instances of the TabStrip on each of my content pages. As each click of a top level tab switches pages and I only need to handle events triggered by clicks on a sub tab, this would probably work for me. If there is some easy solution to my original question, I'd love to see it as it would be cleaner to just have a single instance of the tabstrip, otherwise I probably have an acceptable way to handle the issues.

Regards,

Jim
eo_support
Posted: Sunday, July 8, 2007 11:32:58 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi Jim,

You don't want to do that. That way if you modify the TabStrip, you will have to modify the TabStrip control in each content page, which defeats the purpose of the master page.

You can use the following way to expose the TabStrip to your content page:

Step 1:
Add MasterPage directive in your content page:

Code: HTML/ASPX
<%@MasterType VirtualPath="path_of_your_master_page" %>


This allows you to access your master page from your content page in a strong typed manner.

Step 2:
Expose the TabStrip from the master page:

Code: C#
public partial class MasterPage: System.Web.UI.MasterPage
{
    .....
    public EO.Web.TabStrip MainTabStrip
    {
        get { return TabStrip1; }
    }
    .....
}


This is necessary since by default TabStrip1 is "protected", you will need to expose it as a "public" member in order for the content page to access it.

Now you can access the TabStrip from your content page:

Code: C#
Master.MainTabStrip.SelectedIndex = 1;


It's possible for you to hook up event handler this way, but I wouldn't recommend it because Visual Studio Web Form designer does not support it --- you can do it manually but it can get messy. Generally speaking, if you have to update something (for example, a Label control Label1) in your content page from your master page, you should move that control (Label1 in this case) into your master page.

Thanks
Jim Zuber
Posted: Sunday, July 8, 2007 12:28:28 PM
Rank: Member
Groups: Member

Joined: 6/21/2007
Posts: 12
Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.