Use multiview controls in ASP. NET 2.0

Source: Internet
Author: User
I recently learned a little about the Asp.net 2.0 multiview control. The original Article is published at http://dev.yesky.com/msdn/30/2335530.shtml.

In Asp.net 2.0, many new controls and functions are added, which greatly facilitates developer development. This section describes the use of the added multiview control in Asp.net 2.0. The so-called multiview control is actually a bit like a tabcontrol control that is common in C/S development. You can place multiple "views" (called tabs) on a single page ), for example, you can use the multiview control to allow users to switch to each tab on the same page to view the content, instead of opening a new window each time. This document uses Visual Studio. NET 2005 as an example to describe how to use the multiview control in Asp.net 2.0.

First, open Visual Studio. NET 2005 and create a website. We use the VB.net language. Then, drag a menu control to the web form. This menu control controls the tabs, that is, the interface that is finally displayed in front of the user, and we specify the image style of each tab,CodeAs follows:

<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, drag a multiview control to the web form and place it under the menu control. Note that the multiview control is divided into multiple view tabs for convenience, currently, it is set to three tabs. In each tab, a table is designed. In practice, this table is the content displayed to the user when you click each tab. The Code is as follows:

<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">
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">

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">

Tab View 3
Insert your conent in here
Change selected image URL as necessary
</TD>
</Tr>
</Table>
</ASP: View>
</ASP: multiview>

Finally, we write code for the itemclick event of the menu. In the following code, we set two images to demonstrate the effect. When you click the current tab, the tab image shows the "Selected tab" pattern, while the other two do not click it, it is displayed in gray, the Code is as follows:

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

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.