Solved

Help with Menu Control in ASP.net

Posted on 2006-06-21
5
1,323 Views
Last Modified: 2010-07-27
I have created a menu control for site navagation on my web page.  I have given it a width of 150px.  I also applied an Auto Format so it would have mouse over functions, etc.  The problem is that you have to click on the Menu Item Text for your hyperlink to work.  Becuase my menu has a width of 150px, I have empty space to the right of most of my link descriptions.  But when you roll the mouse the select menu item background changes as it should.  But if you don't mouse click on the text, then the menu doesn't work.  

How can I insure that the link will work if they click anywhere within the menu item region?

Thanks!!!
0
Comment
Question by:accmats
[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
  • 3
  • 2
5 Comments
 
LVL 4

Expert Comment

by:gregg1ep00
ID: 16953158
You can use the <StaticItemTemplate> and <DynamicItemTemplate> to do something like this:

<asp:Menu ID="mnu" runat="server" Orientation="horizontal">
      <StaticItemTemplate>
            <div
            onclick="window.navigate('<%# ResolveUrl( (string) Eval("NavigateUrl") ) %>')">
                  <asp:HyperLink
                  ID="lnk"
                  runat="server"
                  Text='<%# Eval("Text") %>'
                  NavigateUrl='<%# Eval("NavigateUrl") %>' />
            </div>
      </StaticItemTemplate>
      <DynamicItemTemplate>
            <div
            onclick="window.navigate('<%# ResolveUrl( (string) Eval("NavigateUrl") ) %>')">
                  <asp:HyperLink
                  ID="lnk"
                  runat="server"
                  Text='<%# Eval("Text") %>'
                  NavigateUrl='<%# Eval("NavigateUrl") %>' />
            </div>
      </DynamicItemTemplate>
</asp:Menu>
0
 
LVL 4

Expert Comment

by:gregg1ep00
ID: 16953238
Actually, it's working on my system without all the javascript stuff in the client-side onclick handler.  So it looks like the javascript stuff is unnecessary.

<asp:Menu ID="mnu" runat="server" Orientation="horizontal">
      <StaticItemTemplate>
            <div
            style="width:150px;">
                  <asp:HyperLink
                  ID="lnk"
                  runat="server"
                  Text='<%# Eval("Text") %>'
                  NavigateUrl='<%# Eval("NavigateUrl") %>' />
            </div>
      </StaticItemTemplate>
      <DynamicItemTemplate>
            <div
            style="width:150px;">
                  <asp:HyperLink
                  ID="lnk"
                  runat="server"
                  Text='<%# Eval("Text") %>'
                  NavigateUrl='<%# Eval("NavigateUrl") %>' />
            </div>
      </DynamicItemTemplate>
</asp:Menu>
0
 

Author Comment

by:accmats
ID: 16956879
Thanks for your reply.  That worked but is there a way to keep the text from looking like a hyperlink and taking on hyperlink type styles like being underlined and hyperlinked font color?

Thanks for all your help!
0
 
LVL 4

Accepted Solution

by:
gregg1ep00 earned 250 total points
ID: 16956998
You can do that with CSS.  The rule you want to use is:

.MenuItem a,
.MenuItem span
{
   text-decoration: none;
   color: black;
}

.MenuItem .Hover a,
.MenuItem .Hover span
{
   text-decoration: none;
   color: white;
}

Of course, you'll want to adapt this to the CSS you already have for your <asp:Menu> control.  If you're not using any CSS stylesheets, you can use inline styles like this:
<asp:Menu ID="mnu" runat="server" Orientation="horizontal">
     <StaticItemTemplate>
          <div
          style="width:150px;">
               <asp:HyperLink
               ID="lnk"
               runat="server"
               Text='<%# Eval("Text") %>'
               NavigateUrl='<%# Eval("NavigateUrl") %>'
               ForeColor="black"
               Font-Underline="false" />
          </div>
     </StaticItemTemplate>
     <DynamicItemTemplate>
          <div
          style="width:150px;">
               <asp:HyperLink
               ID="lnk"
               runat="server"
               Text='<%# Eval("Text") %>'
               NavigateUrl='<%# Eval("NavigateUrl") %>'
               ForeColor="black"
               Font-Underline="false" />
          </div>
     </DynamicItemTemplate>
</asp:Menu>


Hope that helps!  ;)
0
 

Author Comment

by:accmats
ID: 16960314
Awsome answer.  Thanks for all your help.  I have added an additional question that is related to this one if you think you might can answer it.  THANKS AGAIN!

http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/ASP_DOT_NET/Q_21895574.html
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

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…
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.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

622 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