You are here:   Home
Register   |  Login

Captured Technology - Blog

Minimize

Creating Tabbed Content With the ASP.Net Menu Control

Aug 21

Written by:
8/21/2009 4:16 PM  RssIcon

Creating Tabbed Content With the ASP.Net Menu Control

A recent design required tabbed content on the section page of a website. After doing some research I came upon a solution for tabbed content using the ASP.Net Menu Control. By placing a Menu Control on the page along with a Multiview Control, it is possible to show the different items of the Multiview Control when menu items are selected.

The page markup looks like this:

<table border="0" width="100%">
<tr>
    <td width="151px">
    <asp:Menu
            ID="mnuTabbedContent"
            runat="server"
            Orientation="Vertical"            
            OnMenuItemClick="mnuTabbedContent_MenuItemClick"            
            >
        <Items>
            <asp:MenuItem ImageUrl="~/Images/greentab.png" 
                          ToolTip="Item 1" Text=" " Value="0">asp:MenuItem>
            <asp:MenuItem ImageUrl="~/Images/whitetab.png" 
                          ToolTip="Item 2" Text=" " Value="1">asp:MenuItem>
            <asp:MenuItem ImageUrl="~/Images/whitetab.png" 
                          ToolTip="Item 3" Text=" " Value="2">asp:MenuItem>
            <asp:MenuItem ImageUrl="~/Images/whitetab.png" 
                          ToolTip="Item 4" Text=" " Value="3">asp:MenuItem>
            <asp:MenuItem ImageUrl="~/Images/whitetab.png" 
                          ToolTip="Item 5" Text=" " Value="4">asp:MenuItem>
        Items>
    asp:Menu>
    td>
    <td width="521px">
    <asp:MultiView 
        ID="MultiView1"
        runat="server"
        ActiveViewIndex="0"  >
       <asp:View ID="Tab1" runat="server"  >
            <table cellpadding="0" cellspacing="0">
                <tr valign="top">
                    <td style="width:490px">
            ' Content 1
                    td>
                tr>
            table>
         asp:View>
        <asp:View ID="Tab2" runat="server">
            <table cellpadding="0" cellspacing="0">
                <tr valign="top">
                    <td style="width:490px">
            ' Content 2
                    td>
                tr>
            table>
        asp:View>
        <asp:View ID="Tab3" runat="server">
            <table cellpadding="0" cellspacing="0">
                <tr valign="top">
                    <td style="width:490px">
            ' Content 3
                    td>
                tr>
            table>
        asp:View>
        <asp:View ID="Tab4" runat="server">
            <table cellpadding="0" cellspacing="0">
                <tr valign="top">
                    <td style="width:490px">
            ' Content 4
                    td>
                tr>
            table>
        asp:View>
        <asp:View ID="Tab5" runat="server">
            <table cellpadding="0" cellspacing="0">
                <tr valign="top">
                    <td style="width:490px">
            ' Content 5
                    td>
                tr>
            table>
        asp:View>
    asp:MultiView>
    td>
tr>
table>

While the code to display the desired content is like this:

    Protected Sub mnuTabbedContent_MenuItemClick(ByVal sender As Object, ByVal e As MenuEventArgs) 
Handles
mnuTabbedContent.MenuItemClick ' Show the Content MultiView1.ActiveViewIndex = Int32.Parse(e.Item.Value) ' Make All Tabs White mnuTabbedContent.Items(0).ImageUrl = "~/Images/whitetab.png" mnuTabbedContent.Items(1).ImageUrl = "~/Images/whitetab.png" mnuTabbedContent.Items(2).ImageUrl = "~/Images/whitetab.png" mnuTabbedContent.Items(3).ImageUrl = "~/Images/whitetab.png" mnuTabbedContent.Items(4).ImageUrl = "~/Images/whitetab.png" ' Make Selected Tab Green Select e.Item.Value Case 0 : mnuTabbedContent.Items(e.Item.Value).ImageUrl = "~/Images/greentab.png" Case 1 : mnuTabbedContent.Items(e.Item.Value).ImageUrl = "~/Images/greentab.png" Case 2 : mnuTabbedContent.Items(e.Item.Value).ImageUrl = "~/Images/greentab.png" Case 3 : mnuTabbedContent.Items(e.Item.Value).ImageUrl = "~/Images/greentab.png" Case 4 : mnuTabbedContent.Items(e.Item.Value).ImageUrl = "~/Images/greentab.png" Case Else : mnuTabbedContent.Items(e.Item.Value).ImageUrl = "~/Images/greentab.png" End Select End Sub

Tags:
Categories:

5 comment(s) so far...


Gravatar

Thank you for this post. Many people dont realize this.

Thank you for this post. Learned alot

By Shawn on   8/23/2009 10:19 AM
Gravatar

Re: Creating Tabbed Content With the ASP.Net Menu Control

What seems to be the UI output for this.. You have stated that its for tab features...
It look a little confusing to me but I think that is so helpful in the site..

By Wilson on   8/24/2009 8:16 AM
Gravatar

Re: Creating Tabbed Content With the ASP.Net Menu Control

Thanks for sharing!it is very useful!

By adult chat software on   9/4/2009 5:04 AM
Gravatar

Re: Creating Tabbed Content With the ASP.Net Menu Control

First of all thank for sharing such wonderful information. It will be useful to developers.

By Web Design Company on   9/9/2009 12:18 PM
Gravatar

Re: Creating Tabbed Content With the ASP.Net Menu Control

Creating a CSS friendly Menu Control is a matter of inheriting the ASP Menu control and overloading it's "Render" method to generate CSS friendly code.its a good description which you mention here so clearly..

By Venice Hotels on   9/1/2010 6:11 AM

Your name:
Gravatar Preview
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Security Code
CAPTCHA image
Enter the code shown above in the box below
Add Comment   Cancel 

FaceBook

Minimize

Mobile Version

Minimize
Add CapturedTech - Technology Mippin widget

Translate

Minimize

Sponsors

Minimize

Recent Comments

Minimize
Re: Three Benefits to Using a Royalty-Free Image on Your Website or Blog
I also prefer to use royalty-free images. They give more credibility in your site or blog posts.
Re: Websites vs. Facebook Pages (Infographic)
Internet can be very useful for small business to market them self, there is always some free way to reach your audience via Internet.
Re: Is Keyword Density Still Important For On Page SEO
The search engines hadn’t quite caught up yet. As a result, it wasn’t uncommon to see sites rank highly when their content read something like this.that they follow SEO best practices than you will by trying to figure out a way to get your keywords into your page content another one or two times.
Re: Websites vs. Facebook Pages (Infographic)
Very interesting topic, infographics was a new concept for me, will definitely use it.
Re: Reducing Small Business Blues
Running a business is tough and you are right, most of the time you are the core aspect of each area of a business. I don't think I could handle doing my own accounting, like you I am too terrible with numbers!

u comment, i follow