Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MenuItem clicking cell / box does nothing

Status
Not open for further replies.

jacktripper

Programmer
Dec 5, 2001
124
US
I'm been searching all day trying to find a solution to this. Surely others have figured this out.

I have a .Net menu control with a series of MenuItems. If you click the text of a given MenuItem, the window navigates goes to the correct NavigateURL page. But, clicking anywhere else in the same cell does nothing.

I want the user to be able to click the cell and not worry about hitting the exact text. I tried adding a Menu1_MenuItemClick event, but that only fires if the text is clicked... not the box.

Ideas?

I'm not really keen on having to start from scratch with some kind of ajax/javascript version of the same thing.
 
1. use some javascript to detect the when the cell is clicked and use this information to click the button in the cell.

2. git rid of the menu control and build the menu UI from using repeaters, CSS and javascript.

I would opt for #2.



Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
faq732-7259
 

I found some javascript (see below), but for some reason it causes the cascading table cells to render improperly w/ blank text. And, clicking the main row of cells results in going to home page every time.

The .Net menu control seems pretty worthless if it requires users to click the text only...

<script language="javascript" type="text/javascript">
window.onload = function(){

var menuTable = document.getElementById("<%=MainMenu.ClientID%>"); //specify your menu id instead of Menu1
var menuLinks = menuTable.getElementsByTagName("td");
var menuGet = menuTable.getElementsByTagName("a");
for(i=0;i<menuLinks.length;i++)
{
menuLinks.onclick = function () { test(menuGet.item(0)); }
}
}

function test(str) { window.location = str; }
</script>

 
The .Net menu control seems pretty worthless
agreed. a majority of the web server controls are overly complex and produce horrible html. when i worked with webforms i would use grids and repeaters for complex data binding, everything else was labels, dropdowns and textboxes, etc.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
faq732-7259
 
The menu control is clumsy at best. I would take Jason's suggestion #2 and create the menu with CSS. We opted to do that for all our menus and made life much easier.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top