Hello,
I am force to make a tab control like menu to my asp.net website because of no available tab control shipped with VS studio 2005.
Im having problem when clicking one of the menu and launch the page contain. The Menu selected value are reset to default. what i like is to remember the selection i made so i have a proper back-ground color for the selected menu.
I have 4 pages:
MasterPage: MasterPage.Master
UserControl: TopMenu.ascx
HomePage: Home.aspx
Another Page: OtherPage.aspx
Code Below:
"MasterPage.Master"
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="MasterPage.mas
ter.cs" Inherits="MasterPage" %>
<%@ Register Src="CommonControls/TopMen
u.ascx" TagName="TopMenu" TagPrefix="uc1" %>
<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<uc1:TopMenu id="TopMenu1" runat="server">
</uc1:TopMenu></div>
<div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
"TopMenu.ascx"
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TopMenu.ascx.c
s" Inherits="TopMenu" %>
<asp:Menu ID="Menu1" runat="server" Orientation="Horizontal" BackColor="#FFFBD6" DynamicHorizontalOffset="2
" Font-Names="Verdana" Font-Size="0.8em" ForeColor="#990000" StaticSubMenuIndent="10px"
>
<StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
<DynamicHoverStyle BackColor="#990000" ForeColor="White" BorderWidth="0px" />
<DynamicMenuStyle BackColor="#FFFBD6" BorderWidth="0px" />
<StaticSelectedStyle BackColor="#FFCC66" BorderWidth="0px" />
<DynamicSelectedStyle BackColor="#FFCC66" BorderWidth="0px" />
<DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" BorderWidth="0px" />
<Items>
<asp:MenuItem Text="Home" Value="Home" NavigateUrl="~/Home.aspx">
</asp:Menu
Item>
<asp:MenuItem Text="Other Page" Value="Other Page" NavigateUrl="~/OtherPage.a
spx"></asp
:MenuItem>
</Items>
<StaticHoverStyle BackColor="#990000" ForeColor="White" />
</asp:Menu>
"Home.aspx"
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Home.aspx.cs" Inherits="Home" MasterPageFile="~/MasterPa
ge.Master"
%>
<asp:Content ContentPlaceHolderID="Cont
entPlaceHo
lder1" runat="server" ID="contentHome">
Home Page
</asp:Content>
"OtherPage.aspx"
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="OtherPage.aspx
.cs" Inherits="OtherPage" MasterPageFile="~/MasterPa
ge.Master"
%>
<asp:Content ContentPlaceHolderID="Cont
entPlaceHo
lder1" runat="server" ID="contentOtherPage">
Other Page
</asp:Content>
You can see above that when i click the menu item Home it will go to Home.aspx and Other Page will go to otherpage.aspx. Its ok and no problem. But the active selection of menu will be refresh and get back to default value because usercontrol will then again be called. Because of here i cannot get the feeling of tab control menu like of my website.
Please help. thanks