Solved

how do I change the button bgcolor when it is the selected button?

Posted on 2010-09-20
4
393 Views
Last Modified: 2012-05-10
<div class="clear hideSkiplink">
                <asp:Menu ID="NavigationMenu" runat="server" CssClass="menu"
                    EnableViewState="False"  Orientation="Horizontal" BackColor="#F7F6F3"
                    DynamicHorizontalOffset="2" Font-Names="Verdana" Font-Size="1.1em"
                    ForeColor="#7C6F57" StaticSubMenuIndent="20px">
                    <StaticSelectedStyle BackColor="#5D7B9D" />
                    <StaticMenuItemStyle HorizontalPadding="15px" VerticalPadding="12px" />
                    <DynamicHoverStyle BackColor="#7C6F57" ForeColor="White" />
                    <DynamicMenuStyle BackColor="#F7F6F3" />
                    <DynamicSelectedStyle BackColor="#5D7B9D" />
                    <DynamicMenuItemStyle HorizontalPadding="15px" VerticalPadding="12px" />
                    <StaticHoverStyle BackColor="#7C6F57" ForeColor="White" />
                    <Items>
                        <asp:MenuItem NavigateUrl="~/Default.aspx" Text="Home"/>
                        <asp:MenuItem NavigateUrl="Prod/IPCamera.aspx" Text="IP Camera">                        
                            <asp:MenuItem Text="Installation Manual" NavigateUrl="Prod/IP_Cam_UserManual.aspx" Value="Installation Manual">
                            </asp:MenuItem>
                        </asp:MenuItem>
                        <asp:MenuItem NavigateUrl="Prod/ContactUs.aspx" Text="Contact Us"/>
                        <asp:MenuItem NavigateUrl="~/About.aspx" Text="About"/>
                    </Items>
                </asp:Menu>
            </div>
0
Comment
Question by:goodk
  • 2
4 Comments
 

Author Comment

by:goodk
ID: 33726235
ok, All I am asking is how to change the background color of the button on the menu once the button is clicked.
I tried the following but it did not work
<DynamicSelectedStyle BackColor="White" />
0
 
LVL 26

Accepted Solution

by:
Alan Warren earned 500 total points
ID: 33749559
Hi Goodk,

Think StaticSelectedStyle only works if the menu has a DataSourceID of type SiteMapDataSource and the SitemapDataSource would need a Web.SiteMap.

The following code snippets set the back color of the selected item to light blue.

hth

Alan
Web.SiteMap

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
    <siteMapNode url="~/Default4.aspx" title="Default4"  description="">
        <siteMapNode url="~/Default5.aspx" title="Default5"  description="" />
    </siteMapNode>
</siteMap>


Default4.aspx, Default5.aspx


<%@ Page Language="VB" %>

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

<script runat="server">

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
      <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
      <asp:menu id="NavigationMenu" DataSourceID="SiteMapDataSource1"
        staticdisplaylevels="2"
        staticsubmenuindent="10" 
        orientation="Horizontal"
        runat="server">

        <staticselectedstyle backcolor="LightBlue"
          borderstyle="Solid"
          bordercolor="Black"
          borderwidth="1"/>
      </asp:menu>
    </div>
    </form>
</body>
</html>

Open in new window

0
 

Author Comment

by:goodk
ID: 33766197
but I do not have SiteMapDataSource and I do not even know how if I need to do in this instance.
 
Can you kindly cut and paste my code with the change I need to make to change the background color of the selected menu item.
thanks a lot.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now