Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2010-09-20
4
Medium Priority
?
398 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

722 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