hello people,

I am working on a asp.net project using c# where i need display 1 or more tabs on a web page based on selection of item from drop down list.I am planning to use multiview menu control to give a feel of tabs on web page. can you please tell me is there a way to show \hide these tabs based on my selection from dropdown.

Recommended Answers

All 2 Replies

Add three buttons onto the webpage. Name of three buttons are Button1, Button2, Button3.

After that, place a Multiview onto the page and Drop three View controls inside a MultiView.

Write following code in Button's click event
for Button1_Click

MultiView1.ActiveViewIndex=0

for Button2_Click

MultiView1.ActiveViewIndex=1

for Button3_Click

MultiView1.ActiveViewIndex=2

preliminary idea to
use multiview and view control in asp.net using c#
----------------------------------------------

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        #TextArea1
        {
            height: 62px;
            width: 196px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    </div>
    <p>
        &nbsp;</p>
    <p>
        &nbsp;</p>
    <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
        <asp:View ID="View1" runat="server">
            enter Your name :
            <asp:TextBox ID="TextBox2" runat="server" Width="182px"></asp:TextBox>
            <br />
            <br />
            enter your address :
            <asp:TextBox ID="TextBox3" runat="server" Width="184px"></asp:TextBox>
            <br />
            <br />
            enter yor age :<asp:Button ID="Button1" runat="server" onclick="Button1_Click" 
                Text="Next" Width="101px" />
        </asp:View>
        <asp:View ID="View2" runat="server">
            enter you gender :
            <asp:RadioButton ID="RadioButton1" runat="server" GroupName="r1" Text="male" />
            &nbsp;
            <asp:RadioButton ID="RadioButton2" runat="server" GroupName="r1" 
                Text="female" />
            <br />
            <br />
            enter you city&nbsp; :<asp:DropDownList ID="DropDownList1" runat="server">
                <asp:ListItem>kolkata</asp:ListItem>
                <asp:ListItem>delhi</asp:ListItem>
                <asp:ListItem>pune</asp:ListItem>
                <asp:ListItem>mumbai</asp:ListItem>
            </asp:DropDownList>
            <br />
            <asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text="prev" />
            &nbsp;<asp:Button ID="Button3" runat="server" onclick="Button3_Click" Text="next" 
                Width="154px" />
        </asp:View>
        <asp:View ID="View3" runat="server">
            <br />
            enter comment :
            <textarea ID="TextArea1" name="S1"></textarea><br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <asp:Button ID="Button5" runat="server" onclick="Button5_Click" Text="prev" />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <asp:Button ID="Button4" runat="server" Text="Submit" Width="128px" />
        </asp:View>
    </asp:MultiView>
    </form>
</body>
</html>
-----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
       
        MultiView1.ActiveViewIndex = 1;

    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        MultiView1.ActiveViewIndex = 2;

    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        MultiView1.ActiveViewIndex = 0;
    }
    protected void Button5_Click(object sender, EventArgs e)
    {
        MultiView1.ActiveViewIndex = 1;
    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.