ASP: The submenu items remain visible

I must express my gratitude for the wealth of knowledge this site has provided me with. It has been an invaluable resource for me this year, even though I have scoured every corner and still come up empty-handed.

Allow me to simplify the situation at hand:

  1. There is an ASP:Menu that fetches its data from the database, including parent and child elements linked with IDs.
  2. This data is then passed into a recursive method that constructs the menu items, properly assigning children to their respective parents - all functioning flawlessly.
  3. The next step involves populating the asp:menu control on the webpage - again working perfectly.
  4. Upon completion, the asp:menu gracefully displays the menu items without any issues.

However, here lies the main challenge:

After three painstaking days, despite attempting the simplest approach, I have failed to achieve one goal: displaying all children items of the parents (meaning ALL children) WITHOUT needing to hover over the parents AND without utilizing Javascript. Only pure CSS and HTML combined with C# for the code behind ASP.Net should be used.

I am seeking something along these lines:

  • Transitioning from:

    nav > ul > li:hover > div{
          display: block;
          opacity: 1;
          visibility: visible;
        }

  • To:

    nav > ul > li > div{
          display: block;
          opacity: 1;
          visibility: visible;
        }

The aforementioned code snippet implies that no hover action is required over the parent items to display their children. Essentially, I require a similar solution for my asp:menu's parent-child relationship. Each parent has only 1 level of children without any grandchildren. A single parent can have multiple children before moving on to other parents and their corresponding children.

Below is an example of the data structure I'm dealing with:

  • Company

    |--- About Us

    |--- Services

    |--- Presentation

    |--- Clients

  • Products

    |--- Commercial

    |--- Residential

This is the code snippet for the asp:menu component:

<asp:Menu ID="uxLiteral1" Orientation="Horizontal" runat="server"
OnMenuItemClick="Bottom_Click" SkipLinkText=""
StaticEnableDefaultPopOutImage="False" IncludeStyleBlock="False"/>

While I understand that CSS could potentially solve this issue, I am open to exploring any alternatives available.

I apologize for the lengthy post and appreciate your help in advance!

P.S.: I have already explored the StaticDisplayLevels property but it does not stack the items vertically under each other, making it unsuitable for my situation. I am willing to utilize alternate controls if necessary.

EDIT: Here is the CSS code that was automatically generated by the asp:menu, failing to display the items as intended despite efforts:

.FooterDetails > .Square > #BotMenu1_UpdatePanel1 > #BotMenu1_uxLiteral1 > ul.static
{
    font-weight: bold;
}

.FooterDetails > .Square > #BotMenu1_UpdatePanel1 > #BotMenu1_uxLiteral1 > ul.static > li.static > ul.dynamic > li.dynamic > a.dynamic
    {
        font-weight: normal;
        visibility: visible !important;
        padding-right: 25px;
        margin-bottom: 3px;
    }

The static class represents the parent items such as "Company" and "Products." The dynamic class denotes the children of the static class.

Answer №1

After a long day of struggling with this issue, it finally seems like I've found the solution.

All it took was adding a new CSS class to the asp:menu like this:

<asp:Menu ID="uxLiteral1" runat="server" CssClass="FooterMenu" Orientation="Horizontal"     IncludeStyleBlock="false" StaticEnableDefaultPopOutImage="False"     OnMenuItemClick="NavigationMenu_MenuItemClick" DisappearAfter="0" />

The CSS code needed to be updated so that the menu and its items would only link to the specified class:

div.FooterMenu
{
    align-content: center !important;
}

div.FooterMenu ul
{
    list-style: none;
    display: inline-block !important;
}

    div.FooterMenu ul li
    {
        padding-right: 65px;
        margin-bottom: 3px;
    }

With these changes, you'll achieve the desired result of displaying all child items under each parent without any hover effect. Once again, I feel like the real MVP.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

ASP.NET Core 3.1 dynamic image resizing

<div class="col-md-6"> <div class="border"> <img height="300" width="400" src="~/Images/vg.png" class="rounded"/> <p>This is a sample paragraph.</p&g ...

Unable to Change Mouse Cursor to Pointer when Clicking on Hyperlink in ASP.NET

I have been struggling for hours with a seemingly silly issue in my asp.net core MVC project. Despite setting the cursor to change to a hand pointer when hovering over a href using inline CSS like this: <a href="#" style="cursor:pointer!i ...

Using ASP.NET Server Controls to Toggle Textbox Visibility Based on Dropdown Selection

What is the optimal method for displaying or hiding a textbox or an entire div section based on a user's selection from a dropdown menu? I am uncertain if this can be achieved with server controls, so would it require using standard client-side HTML c ...

Creating dynamic selection options in an HTML select tag using PHP

When retrieving category and sub-category information from an API json file, the API returns category objects with a "parent" attribute. Main category objects have a parent attribute equal to 0, and sub-category objects have the parent attribute equal to t ...

Is there a way to eliminate a div and all its contents from the DOM?

As I work on my web application, I am trying to implement a system where error messages can be returned via ajax upon success or failure. The ajax script is functioning correctly in terms of returning errors or successes. However, my challenge lies in com ...

Partial button clickability issue

There is a puzzling error where the button in the 'red area' is not clickable, and I can't seem to figure out why. Below are images illustrating the issue: https://i.stack.imgur.com/aPfcR.png https://i.stack.imgur.com/v5knZ.png Upon reac ...

How to customize a disabled paper-input element in Polymer 1.0?

Help with Polymer 1.0: I've encountered an issue where setting a paper-input element to 'disabled' results in very light gray text and underline, making it hard to read. I've been trying to use CSS to change the text color but haven&ap ...

What is the process for obtaining the link to attached files in an email?

How can I send an email with attached images and display them within the email? Is there a way to obtain the links of these attached images for embedding in the email? Keep in mind that using remote images may result in the email being flagged as spam by ...

Incorporating CSS styles into a dynamic JavaScript computation

I'm attempting to apply inline CSS to a JS calculation (e.g. 3*2*1) in order to make it appear red. I have experimented with using a span tag, but it only displays the calculation and not the result. I also tried utilizing an internal style sheet. Ho ...

What is the best method for linking my chatbot's user interface to the API.AI server host using either the Python SDK or JavaScript

Looking for a way to seamlessly integrate my chatbot UI, created using HTML and CSS, with the API.AI server using the token provided by API.AI and Python SDK? Below is the HTML code snippet for reference: <!DOCTYPE html> <html> <head> ...

Utilizing Bootstrap 5's table design to occupy the rest of the available vertical

In my .NET Core 7 MVC project, I am facing a challenge where I want to make a details table scroll and occupy the available vertical space on the screen dynamically. I have tried using h-25, h-50 classes to achieve the scrolling effect on the table. Howev ...

Is there a way to dynamically change the title of a tab when new content is added to a minimized page?

Is anyone familiar with how websites like Facebook and Buzzfeed update their tab titles when there are multiple tabs open? I have noticed that sometimes they add a "(1)" or "(2)" to indicate changes on the page. Do they use JavaScript to achieve this eff ...

Adjustable text size to accommodate different cultural changes

My team is working on an MVC web application, with CSS stylesheets utilized in views. We are trying to achieve the following scenario: Whenever the language culture changes from English to another language, we want the font size of a specific class to ...

Struggling to grasp the concept of using z-index in CSS

As a programmer versed in Python, C, Java, and Delphi, I am not a web developer or designer by trade. However, when required to fill those roles, I do my best; please be patient with me. :-) I have created a map (with a background image as a div), where I ...

Hide in certain zones, contextual menu

I recently discovered how to create my own context menu with links based on the div clicked (check out here for more details). However, I am facing an issue now. I am struggling to prevent the context menu from appearing above the specific div boxes where ...

Tips for creating visually appealing tables in ReactJS

For my school project, I need to create a table using ReactJs. I have already created the table but it needs improvement in terms of design. However, I am unsure how to modify my code to achieve the desired look. I tried looking on YouTube for tutorials, b ...

When pasting Arabic text into an input box, the words in HTML appear to be jumbled and shuffled around

When I replicate this text يف عام and input it into a box, the output is shown as follows عام يف ...

Anticipated the presence of a corresponding <tr> in the <table> within the server HTML, but encountered hydration failure due to discrepancies between the initial UI and the server-rendered content

Next.js Version 13.2.3 In Next.js, it is advised not to use the table element. "use client"; export default function index() { return ( <table> <tr> <th>Company</th> ...

Tips for sending multiple values in a data object using jQuery AJAX

I am currently working on a form that contains two input fields, with the possibility of more being added later. The first input is a text field and the second is a checkbox. I want to be able to send these inputs using $.ajax. To accomplish this, I have ...

Is there a way to run both PHP and HTML code using the eval function?

Is it possible to execute HTML and PHP simultaneously using the eval function? eval ("<center> this is some html </center>"); The above code does not yield the desired output, so I am considering changing it to: echo ("<center> this is ...