Add the fallowing code in the page load event and menu item click event.
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
MultiView1.ActiveViewIndex = 0;
}
protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
{
MultiView1.ActiveViewIndex = Int32.Parse(Menu1.SelectedValue);
}
<div>
<asp:Menu ID="Menu1" runat="server" OnMenuItemClick="Menu1_MenuItemClick" Orientation="Horizontal"
style="left: 1px; position: relative; top: 30px" Height="38px" Width="127px" >
<StaticMenuStyle HorizontalPadding="0px" VerticalPadding="0px" />
<StaticSelectedStyle BackColor="#C0C0FF" BorderColor="#C0C0FF" />
<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>
<StaticHoverStyle BackColor="Silver" />
<StaticMenuItemStyle BorderColor="#404040" BorderStyle="Solid" BorderWidth="1px" />
</asp:Menu>
</div>
<div style="width: 429px; height: 191px; background-color: #C0C0FF;">
<asp:MultiView ID="MultiView1" runat="server">
<asp:View ID="View1" runat="server">
<br /> CONTENTS OF TAB1 (view1).</asp:View>
<asp:View ID="View2" runat="server">
<br />
CONTENTS OF TAB2(view2)<br />
</asp:View>
<asp:View ID="View3" runat="server">
<br />
CONTENTS OF TAB3(view3)</asp:View>
</asp:MultiView>
</div>
Very informative post. It's really helpful for me and helped me lot to complete my task. Thanks for sharing with us. I had found another nice post over the internet which was also explained very well about View Control in ASP.Net, for more details of this post check out this link...
ReplyDeletehttp://mindstick.com/Articles/35fb463b-8bca-4a53-a194-fc86f09899ee/?View%20Control%20in%20ASP.Net
Thanks everyone for your precious post.