Is utilizing Eval on a div within a DataList ItemTemplate feasible for MouseOver event handling?

Apologies for the complicated title.

Here is the structure of my DataList:

<asp:DataList ID="DataListFloor" runat="server" RepeatColumns="5" >
    <ItemTemplate>
        <div style='width:199px;height:166px;background-color: <%# Eval("background") %>'>
            <div style="width: 199px; height: 22px; overflow: hidden;">
                <div style="box-sizing: border-box; width:97px; float:left;">
                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("Name")%>'></asp:Label>
                </div>
            </div>
        </div>
    </ItemTemplate>
</asp:DataList>

The datatable used to bind to this DataList is as follows:

Name    background  background_mouseOver
----------------------------------------
Joe     Yellow      Orange
Mary    white       Beige
Jane    Red         Maroon
Carl    gray        Darkgray

The background-color of the div element is set to the value in the column background. The Eval function for this attribute is functioning correctly.

My query is: how can I modify the background-color of the div on MouseOver to match the value in the datatable column background_mouseOver? For instance, when hovering over an item displaying Joe, the background-color should change from Yellow to Orange.

Kindly refrain from using jquery for the solution.

Many thanks.

Answer №1

My solution for utilizing the onMouseover event was as follows:

<div onMouseover="this.style.backgroundColor = '<%# Eval("background_mouseOver")%>'" style='background-color: <%# Eval("background") %>'>
</div>

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

After stopping the interval with clearInterval(), you can then use the res.send method

I need to continuously log the current date and time to the server console then stop logging after a specified time, returning the final date and time to the user. How do I properly utilize ClearInterval() in this scenario? const express = require(" ...

Failure of jQuery Code Upon Successful Execution

I'm having an issue with my jQuery ajax code. It's functioning perfectly, but I can't seem to get it to change the class of the button that triggers the event when it is successful. The code under success: does not seem to be working as inte ...

Utilize php readfile to fetch and display numerous image files

I am attempting to retrieve and display multiple image files from a folder that is protected by a .htaccess file using PHP's readfile() function. The issue I am encountering is that only the first image is successfully read and displayed in the brows ...

How can I make sure that index.php displays the current page when I am navigating through categories on the WordPress

In my WordPress website, I have set up categories in the main navigation. Specifically, I have a category named "Home" which corresponds to category 4. To display the Home category (start page), I have added the following code to my index.php file: <?p ...

Is it possible to sync flash video across multiple computers?

Planning an event where we require the following setup: We need multiple computers to run a quiz using asp.net. Each computer will play a video as a background in the browser, similar to a screensaver with advertising. When the mouse is moved, a div will ...

The Art of HTML and CSS Layouts

My code is displaying a layout where the 'Login or Signup' link is not aligning to the right side of the page as intended. Can anyone help me with this issue? HTML <header> <h1>Heading</h1> <p>A clean, minimal, gri ...

display select items from a webpage

Despite researching many topics, I am still unable to get this to work. My goal is to hide certain elements on my webpage when the user tries to print it. I am currently using Bootstrap 5, which includes the following CSS: @media print{.d-print-none{disp ...

Unexpected behavior is being observed after incorporating the 'node' environment into my .eslintrc file

My project is currently using eslint v1.8.0 to analyze the test.js file: require('fs'); var a = 1; Initially, my .eslintrc file is empty: { } After running eslint test.js, I get the following errors: 1:1 error "require" is not defined ...

Ensuring the perfect alignment of a Bootstrap icon within a circular container

I am attempting to achieve a circular border around an icon to match the design. While I can center the icon without the container, the challenge arises when trying to keep it centrally aligned within the round container. Any suggestions? <div class=" ...

What's more efficient in terms of performance, checking for a class versus adding a class?

When dealing with a function that triggers on a scroll event, which method is more efficient? Checking if a class is already added and adding it if not Simply adding the class without any checks each time $(document).on('scroll', function ( ...

Removing the column name from a JSON return in C# involves using a variety of techniques

Below is a JSON output I have received : [ { positionCode: "POS1", positionName: "POSITION 1", positionDescription: "", parentPosition: "POS2", }, { positionCode: "POS2", positionName: "POSITION ...

UPDATE: An issue has been identified with the /login route that is currently causing an unknown error

Hours of coding and suddenly my app is rendering everything twice. Can't figure out why, please help! https://i.sstatic.net/RhMid.png app.js import { BrowserRouter as Router, Switch, Route } from "react-router-dom"; import "bootstrap/ ...

Experiencing issues with this.$refs returning undefined within a Nuxt project when attempting to retrieve the height of a div element

I am struggling with setting the same height for a div containing Component2 as another div (modelDiv) containing Component1. <template> <div> <div v-if="showMe"> <div ref="modelDiv"> <Comp ...

A guide on integrating MongoDB, Mongoose, Express JS, and Node JS for effectively adding prices

Currently adding various documents to the database: await TestMOdel.insertMany([ { Model: "Samsung", price: 45000, OS: "MS DOS", }, { Model: "Wipro", pr ...

Converting a timestamp to a date format within AngularJS interpolation

Is there a way to send a timestamp, such as 1519357500, to HTML and then convert it into a date format while using interpolation? I attempted the following approach but unfortunately it did not work: {{moment($ctrl.myTimestamp).format('MMMM Do YYYY, ...

Styling Options for Material-UI Tables: Enhancing the Look of Your Table Components

I am working with 'material-ui' and attempting to change the color of a table element based on its value. In the code snippet below, I have tried to make the background color go red if the cell value is "Out of Zone". However, even though the tab ...

Create a CSS animation that causes a div element to smoothly float out of the document

I want to add a CSS animation featuring clouds moving from left to right. In my design, I have a div with a 100% width containing cloud images styled with "position:absolute". My initial approach was simple: create an animation that gradually changes the " ...

Is there a possibility of encountering an endless update loop within a component's render function?

Hello! I am a beginner in Vue.js and I have encountered an issue with my function. Instead of increasing my variable to 1 as expected, it is increasing it to a random number every time. The console is displaying the following error message: "You may hav ...

Clickable Parent URL in Bootstrap 5 Dropdown

I'm currently working on creating a Bootstrap 5 Navabar with a dropdown that appears on hover and allows the parent item to be clickable on screens larger than 992px. Successfully implementing the show on hover feature with the following JavaScript: ...

Tips for increasing visibility for your Google Analytics Embed API Custom Components

I recently tried to incorporate some code I found at the following link: After downloading the files view-selector2 and date-range-selector, I saved them in my local directory. I made a modification to the code: var accountSummaries = require(['&ap ...