Use the Menu control and MuliView control in combination

Source: Internet
Author: User

We may use the tab control sometimes in the project. We can use the Menu and MuliView controls together to solve this problem. Let's take a look.

Next let's take a look at the original code:

Code
<Head runat = "server">
<Title> No title page </title>
<Style type = "text/css">
Html
{}{
Background-color: silver;
}
. MenuTabs
{}{
Position: relative;
Top: 2px;
Left: 2px;
Width: 137px;
Height: 19px;
}
. Tab
{}{
Border: solid 1px black;
Border-bottom: none;
Background-color: # eeeeee;
}
. SelectedTab
{}{
Border: solid 1px black;
Border-bottom: solid 1px white;
Background: white;
}
. TabBody
{}{
Border: solid 1px black;
Padding: 20px;
Background-color: White;
}
</Style>
</Head>
<Body>
<Form id = "form1" runat = "server">
<Div>
<Asp: Menu ID = "menuTabs" CssClass = "menuTabs" StaticMenuItemStyle-CssClass = "tab"
StaticSelectedStyle-CssClass = "selectedTab"
Orientation = "Horizontal" runat = "server" onmenuitemclick = "menuTabs_MenuItemClick"
>
<Items>
<Asp: MenuItem Text = "tab1" Value = "0" Selected = "true"> </asp: MenuItem>
<Asp: MenuItem Text = "tab2" Value = "1"> </asp: MenuItem>
<Asp: MenuItem Text = "tab3" Value = "2"> </asp: MenuItem>
</Items>
</Asp: Menu>
<Div class = "tabBody">
<Asp: MultiView ID = "MultiView" ActiveViewIndex = "0" runat = "server">
<Asp: View ID = "view1" runat = "server"> fdsa4 <asp: TextBox ID = "TextBox1" runat = "server"> </asp: textBox> </asp: View>
<Asp: View ID = "view2" runat = "server"> fdsafdsa5555 <asp: ImageButton ID = "ImageButton1" ImageUrl = "~ /Image/s.jpg"
Runat = "server" Width = "144px" Height = "35px"/> </asp: View>
<Asp: View ID = "view3" runat = "server"> fd66666666666 <asp: DropDownList ID = "DropDownList1" runat = "server">
</Asp: DropDownList>
</Asp: View>
</Asp: MultiView>
</Div>
</Div>
</Form>
</Body>
</Html>

Here, we must use CSS to complete the job. In this way, we have not completed the job yet and we have to make it happen,
Click a Tab to get the items in this TAB. we have to write an event Code in Mune.
Protected void menuTabs_MenuItemClick (object sender, MenuEventArgs e)
{
This. MultiView. ActiveViewIndex = Int32.Parse (menuTabs. SelectedValue );
}

In this way, the ID value is displayed in the Tab, which is so simple;

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.