Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2010-09-20
4
Medium Priority
?
400 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
3 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
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…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

772 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