Attempting to override the default system appearance in CSS for ASP.NET is ineffective

I am currently working on creating a CSS style that can modify the appearance of a dropdown control to look like a label, while allowing another dropdown on the same page to retain its default appearance. To achieve this, I am using a custom attribute with the controls and applying the same attributes in the CSS. Here is an example code snippet:

In this scenario, I have two dropdowns - the first one should display as a label and the second one should be editable.

I have added a custom attribute to the second dropdown to enable editing, but despite overwriting it with the default appearance, the dropdown arrow key does not appear.

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default4.aspx.vb" Inherits="Default4" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server" title="test">
    <title>TEST</title>
    <style type="text/css">

        .DropdownList, .DropdownListRequired {
            border-radius: 5px;
            -webkit-border-radius: 5;
            font-family: Calibri,"Helvetica Neue", Helvetica, Arial, sans-serif;
            padding: 1px 1px 1px 1px;
            border: none;
            transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
            color: #1E2935;
            line-height: 1;
            font-size: 13.5px;
            background-color: transparent;
            pointer-events: none;
            -ms-user-select: none;
            tab-index: -1;
            cursor: default;
            opacity: 0.55 !important;
            -webkit-appearance: none;
            -moz-appearance: button-arrow-down;
            border: none;
        }
        .DropdownList[view=readonly-edit] {
            -webkit-appearance: default-button;
            -moz-appearance: button-arrow-down;
            padding: 5px 2px 5px 2px;
            border: 3px solid #2111f3;
            color: #ff0000;
            line-height: 1.4285;
            pointer-events: auto;
            -ms-user-select: auto;
            cursor: auto;
            background-color: white;
            opacity: 1 !important;
        }               
    </style>
    <script lang="javascript" src="Scripts/jquery-1.9.1.min.js" type="text/javascript"></script>
</head>

<body>

    <form id="form1" runat="server">
        <div>
            <asp:DropDownList ID="ddlSearchApplicationStatus" CssClass="DropdownList" runat="server" Width="170px">
                <asp:ListItem>Test1</asp:ListItem>
                <asp:ListItem>Test2</asp:ListItem>
                <asp:ListItem>Test3</asp:ListItem>
                <asp:ListItem>Test4</asp:ListItem>
            </asp:DropDownList>
            <asp:DropDownList ID="DropDownList1" CssClass="DropdownList" runat="server" Width="170px" view="readonly-edit">
                <asp:ListItem>Opt1</asp:ListItem>
                <asp:ListItem>Opt2</asp:ListItem>
                <asp:ListItem>Opt3</asp:ListItem>
                <asp:ListItem>Opt4</asp:ListItem>
            </asp:DropDownList>

            <%--<asp:Button ID="Button1" runat="server" Text="Expire Cookie" OnClientClick="return ExpireCookie();" />--%>
        </div>
    </form>

</body>

The second dropdown is currently displaying incorrectly, lacking the down-arrow indicator which is necessary for user interaction. I aim to rectify this issue so it appears correctly with its default styling.

https://i.sstatic.net/AaS3A.jpg

Answer №1

Upon further investigation, I have identified the issue. Instead of using

-webkit-appearance:default-button
, it should be -webkit-appearance:menulist.

.DropdownList[view=readonly-edit] {
            -webkit-appearance: menulist;
            -moz-appearance: menulist;
            padding: 5px 2px 5px 2px;
            border: 3px solid #2111f3;
            color: #ff0000;
            line-height: 1.4285;
            pointer-events: auto;
            -ms-user-select: auto;
            cursor: auto;
            background-color: white;
            opacity: 1 !important;
        }   

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 extracting HTML content from JSON data as valid HTML code

I am attempting to extract HTML content from a JSON object response.indexText, which has been validated with JSONLint. { "indexText": "<div id=\"content-home\"><h1> Hello World! <\/h1> <p>Some text.<\/p> ...

Event listener is failing to trigger when clicked in content script and directed to popup on Google Chrome Extension

I created a button within a popup using jQuery click event in a content script, but it is not working. How can I attach a click event to the button by Element ID? It is worth noting that the jQuery Document Load event is functioning properly. The followin ...

In CSS, Internet Explorer fails to recognize the margin-bottom property of the last div

I have a container with three divs: header, content, and footer, set up in a standard application format. Here is the structure: <body> <div> <div id="ROOT" > <div id="ROOT_0" > Header ...

improper rendering of highcharts

Receiving data in JSON format as shown below: <?php $monthlyParticipation='[{"project_title":"test project 44","project_ref_id":"113","amount":"13000.00","months":"Feb"},{"project_title":"sdsdsd","project_ref_id":"112","amount":"50000.00","months ...

Task Failure: Unable to Deploy Azure Websites

Since 10AM CST today, I have been experiencing issues deploying my website on Azure Websites. The error message states that the web deployment task failed due to a connection issue with the remote computer ("waws-prod-chX-XXX.publish.azurewebsites.windows. ...

IE 8 behaves in varying ways depending on the computer it is used on

Why might IE 8 behave differently on two separate machines? Specifically, when visiting this site: One machine experiences the issue of the "X" disappearing and not being able to minimize a slideshow after maximizing it. However, on another machine, even ...

Tips for organizing list items in a grid format using CSS and HTML

In my div block, the width is not fixed. Inside the div, there is a list block with 11 items that I want to display evenly like this: ##item## ##item## ##item## ##item## ##item## ##item## ##item## ##item## ##item## ##item## ##item## I&a ...

What is the best way to show a progress bar while waiting for an entire aspx page to finish

Is there a way to display a progress bar on my default.aspx page until the entire page is loaded? I currently have a master page called Root.master. I attempted to use the following code: <html> <head><title>xx</title> </head&g ...

Ensuring that your content expands to fit the sidebar dimensions

I have diligently searched for a solution to my issue both on Google and here, but have yet to find one that works. I've experimented with various CSS properties like display: table-cell and inline-block, as well as different overflow options, but not ...

showing data retrieved from the database

While working with asp.net and c#, I ran some database operations to display data in a form but encountered a blank screen. Clicking the button should populate the form with values from the database without using gridview or datagridview, however, this fun ...

Interactive tables with popup buttons powered by jQuery Datatables

How can I implement a button to trigger a dialog based on the row it is located in? Below is the code I am using: The button has the class dlg-outletpart-btn: Below is the jQuery JavaScript code snippet: <script> /*datatables script function below ...

Angular has the capability to rewrite URLs in CSS, providing a unique way

An issue arises in Angular when using a base set and html5mode with SVGs. This causes things like filter: url(#url) to be rewritten as filter: url(/base/#url). https://github.com/angular/angular.js/issues/8934 Disabling html5 mode and removing the base d ...

Steps for clearing the UIWebView application cache for HTML5 applications

I recently encountered a problem where the HTML5 application cache stopped working in a native container using UIWebView to display HTML content. The cache.manifest file was updated, and UIWebView started downloading the process but failed at a specific ...

What are some strategies for speeding up the build time when creating a website in visual studio?

Is it possible that having numerous classes in the App_Code directory could lead to issues? Would relocating them to a separate library improve build speed? Any other suggestions or best practices to share? ...

Forced line break at particular point in text

I would love to implement a line break right before the "+" character, either using css styling or through a different method. Is this task achievable? #myDiv{ width: 80% } #myP{ c ...

unable to establish a connection to SQL in [PHP]

I'm having an issue with my code and need some help fixing it. The website is supposed to allow users to add, edit, and delete data. However, when I fill out the fields and click "add", it redirects me to a blank page. Here's the code that I have ...

Utilizing Jquery in the Customer Portal feature within the Salesforce platform

Struggling to incorporate a Visualforce page with Jquery UI and Salesforce Customer Portal. Unfortunately, Jquery UI seems to be taking precedence over the Standard Salesforce stylesheet. Is there a way to prevent this from happening? Any assistance on t ...

Stopping the interval in Javascript on button press

Struggling to make clearInterval work properly when connected to a button click action. Also, the function seems to be activating on its own... Take a look at my code below var funky = setInterval(function() { alert('hello world'); }, 2000); ...

Ember's distinctive feature: Named Block Helpers

Can we create "named blocks" in a different way? For instance, {{#customBlock "repeatableBlock"}} {{!-- block containing numerous properties and data that may become messy if hardcoded multiple times --}} {{/customBlock}} Then, elsewhere in the code, {{ ...

Creating a dynamic HTML5 video player with Fancybox and VideoJS

What is the best way to ensure that an HTML5 video remains responsive inside a fancybox that is already responsive? Here is the code that I currently have: <a class="preview" href="#inline123"> <img class="item" src="/thumbs/thumb.jpg" widt ...