Trouble with DevExpress ASPxButton: Some Properties Fail to Update

It's been a while and I'm facing a tough challenge. I need to change the image source of an ASPxButton from the code behind, but it seems like the height, width, and border style are getting lost in the process (resulting in an image with its own size and a thick black border).

<dx:GridViewDataTextColumn FieldName="SyncStatus" VisibleIndex="0" Caption=" " Width="22px">
    <DataItemTemplate>
       <dx:ASPxButton runat="server" Image-Url="~/Images/Wizard/Wand24x24.png" Height="20px" Width="20px" 
        Border-BorderStyle="None" id="btnWiz" OnInit="btnWiz_Init"></dx:ASPxButton>
    </DataItemTemplate>
 </dx:GridViewDataTextColumn>


    Protected Sub btnWiz_Init(sender As Object, e As EventArgs)

    Dim btnWiz As ASPxButton = TryCast(sender, ASPxButton)
    Dim container As GridViewDataItemTemplateContainer = TryCast(btnWiz.NamingContainer, GridViewDataItemTemplateContainer)

    btnWiz.ImageUrl = "~/Images/NewNote.png"
    btnWiz.Border.BorderStyle = BorderStyle.None
    btnWiz.Border.BorderWidth = Unit.Pixel(0)
    btnWiz.Height = Unit.Pixel(20)
    btnWiz.Width = Unit.Pixel(20)

End Sub

I attempted a solution by adding the following:

 .dxbButton
   {
     border-style: none;
     height: 20px;
     width: 20px;
    }

However, upon inspecting the element, it appears that this solution is being ignored. Any advice would be greatly appreciated. Thank you in advance.

Answer №1

Your CSS isn't being applied due to inline styles taking precedence

Setting Height="20px", Width="20px", Border-BorderStyle="None"

results in inline styles being generated, resulting in:

<div style="border-style:None; height:20px; width:20px; -moz-user-select:none;" ...

These inline styles override your CSS rules

Answer №2

It seems that a small tweak in the syntax was all it needed (just as I thought). The correct syntax is

    btnWiz.Image.Height = 20
    btnWiz.Image.Width = 20

I'm certain this information is well-documented somewhere. It also resolved the border problem.

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

Tips for positioning a Material UI Button and TextField side by side, perfectly aligned on the same line and height

I am currently working on aligning a <Button> from the Material UI library so that it is positioned at the same height as the <TextField> next to it and perfectly aligned with that field. Both the <Button> and the <TextField> are e ...

Sliding Up Transition Effect for Footer with JQuery or CSS3

I am attempting to replicate a sleek slide up footer that caught my eye on The Internship Movie Site. I have created the wireframe layout, but I am struggling to figure out the correct CSS transition effect. Although I have experimented with the "top" and ...

Adjust the color of static hyperlinks based on the background color

Is there a way to dynamically change the color of my fixed side links based on the background color when scrolling? I attempted to use CSS mixed-blend-mode: difference, but it does not provide the level of control I need. Therefore, I am looking to achieve ...

Extracting Menu Information from Weedmaps

I've been attempting to extract menu data from dispensaries listed on weedmaps.com, but I'm struggling to understand how the website is structured and where the relevant information is located for scraping. My goal is simple: I want to retrieve ...

Transitioning between sections by clicking on a navigation menu item

I'm looking to create a cool animation effect on my website. When a user clicks on a specific menu link, such as "about-section," I want the page to smoothly scroll down to that section in a parallax style. If anyone knows of a jQuery plugin that cou ...

What is the best way to hide the black icons (x) and bars on larger screens and which specific CSS code should I use to achieve this?

I'm attempting to display menu icons only on smaller screens like phones or tablets, and text on larger screens such as laptops or desktops. I've experimented with adjusting the media query and CSS, but haven't had any success. What specific ...

Stop automatic scrolling when the keyboard is visible in Angular

I have created a survey form where the user's name appears on top in mobile view. However, I am facing an issue with auto scroll when the keyboard pops up. I want to disable this feature to improve the user experience. <input (click)="onFocusI ...

Is it possible to target an iframe and display text simultaneously?

Trying to create a unique menu that interacts with an iframe and displays text in a separate div upon clicking. Example: • Menu item 1 clicked. • "https://wikipedia.org" loads in the iframe. • Address of the wikipedia page displayed in a diffe ...

Positioning of the dropdown in Material UI AutoComplete menus

Is there a way to turn off autocomplete auto position? I would like the autocomplete options to always appear at the bottom. Check out this link for more information! ...

Embed a style sheet in the PHP email sending function

Is there a way to integrate an entire stylesheet into an email using PHP's mail() function in order to maintain proper styling? I have a large CSS file designed specifically for CKEditor that needs to be included to ensure the email displays correctly ...

Animation does not trigger before switching pages

I'm attempting to create an animation that occurs before the page transitions. After finding a jQuery script on this site and tweaking it to match my HTML, I realized the code works in a fiddle but not on my actual page. Any assistance would be greatl ...

The float right attribute doesn't stay contained within the box; instead, it drifts outside the box

I've been struggling to keep this box fixed at the top of the browser, but I'm facing an issue with the positioning on the right side. I can't seem to figure out how to solve it, so I'm reaching out for some help. #StickyBar #RightSide ...

What are the best scenarios for using %, em, or ex units in CSS font styles?

I'm trying to figure out in what situations I should use %, em, and ex as font units of measurement in CSS. Can someone provide some clarity on this for me? I'm feeling a bit confused. ...

What is the best way to switch between components when clicking on them? (The component displayed should update to the most recently clicked one

I am facing a challenge in rendering different components based on the navbar text that is clicked. Each onclick event should trigger the display of a specific component, replacing the current one. I have 5 elements with onclick events and would like to re ...

Using jQuery to dynamically change the CSS color based on the background-color of a checkbox label

When a checkbox is selected, the function below runs to change the text color to white or black based on the darkness of the background color. However, the third checkbox should trigger this change to white but currently does not. function isDark(color) { ...

Overflow - conceal the scrollbar and prevent scrolling without cutting off the element

Whenever I implement the code snippet below: body { overflow: hidden; } The overflowing element gets clipped. However, when I try this code instead: body { overflow: auto; } The element is no longer clipped, but now a scrollbar appears where it ...

CSS problem: Chrome scrolling overflow glitch (ghost margin/padding)

Hey there, I've run into a bit of an issue with two divs containing tables - one acting as a header and the other as a scrollable content area. Everything is working perfectly except for this mysterious border/margin that keeps appearing in Chrome on ...

What is the mechanism through which a flexbox enlarges to accommodate its overflowing child elements?

I am working with a flexbox layout. Here is the HTML code structure: <div class="grid"> <div class="row"> <div class="column">Content</div> <div class="column">Content2</div> <div class="column">Con ...

is it possible to adjust the height of a tableRow in mui?

I recently created a table component using Mui. I've been attempting to adjust the height of the tableRows, but so far I haven't had any success. Below is my code snippet: import React, { memo } from "react"; import { ActionItemType, ...

How can I fix the issue where Sx is not converting the styles to CSS format for the fill property exclusively?

The primary-main is supposed to change color to something like #abcdefg, but it seems to be stuck displaying primary-main as is. I am working with angular MUI + React ...