Solved

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

Posted on 2010-09-20
4
390 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

746 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

11 Experts available now in Live!

Get 1:1 Help Now