|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
IntroductionRecently, I had been writing a small web scrapping application using ASP.NET 2.0. During which time I was trying to investigate some of the new controls available in ASP.NET 2.0. One of the 2.0 controls that I found particularly interesting was the About the controlWhen I approached writing my simple tab control, I had this article in the back of my mind, CSS and Round Corners: Build Accessible Menu Tabs: a nice article on how to make a tab control using CSS tricks and images. What I wanted to do was combine the ideas in this CSS article with the ASP.NET First, I dropped a <asp:Menu
ID="Menu1"
Width="168px"
runat="server"
Orientation="Horizontal"
StaticEnableDefaultPopOutImage="False"
OnMenuItemClick="Menu1_MenuItemClick">
<Items>
<asp:MenuItem ImageUrl="~/selectedtab.GIF"
Text=" " Value="0"></asp:MenuItem>
<asp:MenuItem ImageUrl="~/unselectedtab.GIF"
Text=" " Value="1"></asp:MenuItem>
<asp:MenuItem ImageUrl="~/unselectedtab.GIF"
Text=" " Value="2"></asp:MenuItem>
</Items>
</asp:Menu>
Next, I put my <asp:MultiView
ID="MultiView1"
runat="server"
ActiveViewIndex="0" >
<asp:View ID="Tab1" runat="server" >
<table width="600" height="400" cellpadding=0 cellspacing=0>
<tr valign="top">
<td class="TabArea" style="width: 600px">
<br />
<br />
TAB VIEW 1
INSERT YOUR CONENT IN HERE
CHANGE SELECTED IMAGE URL AS NECESSARY
</td>
</tr>
</table>
</asp:View>
<asp:View ID="Tab2" runat="server">
<table width="600px" height="400px" cellpadding=0 cellspacing=0>
<tr valign="top">
<td class="TabArea" style="width: 600px">
<br />
<br />
TAB VIEW 2
INSERT YOUR CONENT IN HERE
CHANGE SELECTED IMAGE URL AS NECESSARY
</td>
</tr>
</table>
</asp:View>
<asp:View ID="Tab3" runat="server">
<table width="600px" height="400px" cellpadding=0 cellspacing=0>
<tr valign="top">
<td class="TabArea" style="width: 600px">
<br />
<br />
TAB VIEW 3
INSERT YOUR CONENT IN HERE
CHANGE SELECTED IMAGE URL AS NECESSARY
</td>
</tr>
</table>
</asp:View>
</asp:MultiView>
Last, I wired the Protected Sub Menu1_MenuItemClick(ByVal sender As Object, _
ByVal e As MenuEventArgs) Handles Menu1.MenuItemClick
MultiView1.ActiveViewIndex = Int32.Parse(e.Item.Value)
Dim i As Integer
'Make the selected menu item reflect the correct imageurl
For i = 0 To Menu1.Items.Count - 1
If i = e.Item.Value Then
Menu1.Items(i).ImageUrl = "selectedtab.gif"
Else
Menu1.Items(i).ImageUrl = "unselectedtab.gif"
End If
Next
End Sub
In this event, you can see that I set the pertinent view to be visible based upon which tab (really a This control basically rides on some basic CSS styling and the ASP.NET Hope you can find some use for it.
|
||||||||||||||||||||||