Control style overridden - asp.net

I have the following ASP.Net code
...
<div style="width: 40%; float: left; margin-left: 15px">
<b>County:</b>
<asp:ComboBox ID="cboCounty" runat="server" MaxLength="0"
AutoCompleteMode="SuggestAppend" CssClass="EPSCombo">
</asp:ComboBox>
<br />
...
The problem: This div contains many combobox's and they are not showing as expected, they all have EPSCombo class. and when I debug the CSS I find that it is being overridden, here is the output from FireBug
My EPSCombo style is as follows (overriding the default AjaxToolkit CSS)
.EPSCombo .ajax__combobox_inputcontainer .ajax__combobox_textboxcontainer input
{
margin: 0;
border: solid 1px #7F9DB9;
border-right: 0px none;
padding: 1px 0px 0px 5px;
font-size: 13px;
height: 18px;
}
.EPSCombo .ajax__combobox_inputcontainer .ajax__combobox_buttoncontainer button
{
margin: 0;
padding: 0;
background-image: url(../images/windows-arrow.gif);
background-position: top left;
border: 0px none;
height: 21px;
width: 21px;
}
.EPSCombo .ajax__combobox_itemlist
{
border-color: #7F9DB9;
}
And the CSS file containing EPSCombo is the last one included in the Master page.
Question: It might had been a while since I did web development, but if I decide the CSS class for a control shouldnt that have the highest priority and should override everything else, correct? If so, then why is my combobox style (Height, Width, margin, and padding) is being overridden?? I dont have any other style class that set the height and width for those values shown in Firebug.
Update after Loki's answer I thought I should add this, adding !important to these attributes would solve the problem, but I want to get to the root cause of this and see where things went wrong.

Your ComboBox may be inheriting it's styling from the <div> it is contained in, or from a div higher than that. Since you have not specified a 'class' or 'ID' attribute for the div that it is contained within, that div may be retrieving style from your CSS file if you have something like:
div
{
height: 21px;
margin: 0px;
padding: 0px;
width: 21px;
}
To force your ComboBox to take independent styling though you may use the asp style attribute like so:
<asp:ComboBox ID="cboCounty" runat="server" MaxLength="0"
AutoCompleteMode="SuggestAppend" style="margin: 0;padding: 0;height: 21px;width: 21px;">
</asp:ComboBox>
That should be the highest priority over any other styling that may be interfering in your application. Although considered improper programming practice it may help you narrow down the issue.
Cheers, Eric
EDIT I should also mention that your CSS code is interpreted in order from the most specific to least specific tag definitions. Ex, div.menu is more specific than div, this may be occurring somewhere else in your style-sheet.
This is also a good article to look at describing inheritance. Hope this helps!

A quick fix - add !important flags to your stylesheet. They'll have higher priority over everything else, unless there are other flags defining the very same property of the very same element

Related

Why is SmartGWT overriding my CSS?

I’m tasked with developing a widget with buttons in SmartGWT (enterprise). The design calls for borders around the buttons. I’ve designed the CSS for this. However, SmartGWT insists on overriding my CSS border definition by filling in the “style” attribute on the generated TD. The docs for Canvas.setBorder actually say “This property applies the same border to all four sides of this component. Different per-side borders can be set in a CSS style and applied via styleName.” Clearly, it’s meant to be able to control border definitions with CSS.
I realize that I could just call setBorder with a concrete border definition, but I need to have different borders based on state (hover, down, etc.)
For example, the button label is “Review”. Here is the generated HTML:
<td class="controlButton" style="border: currentColor; border-image: none; text-align: center; padding-top: 0px; padding-bottom: 0px; vertical-align: middle;">
<div style="vertical-align: middle; display: inline-block; white-space: nowrap; max-width: 100%;">
<div id="isc_1G" overflow: hidden; vertical-align: middle; display: inline-block; -ms-text-overflow: ellipsis; max-width: 100%; box-sizing: border-box;">Review</div></div></td>
In my CSS, I have a class (controlButton) defined with a border, but the explicit border declaration in the “style” overrides it.
Here’s the code where I create the button:
Button button = new Button(“Review”);
button.setBaseStyle(“controlButton”);
button.setBorder("inherit");
button.setHeight(28);
I’ve also tried not calling setBorder, calling setBorder(null), and as above, setBorder(“inherit”). Nothing affects the inline style.
Here’s the CSS (omitting all of the state definitions for brevity):
.controlButton {
background-color: #353535;
text-align: center;
font-size: 14px;
vertical-align: middle;
padding: 2px;
margin: 2px;
border-radius: 5px;
border: 1px solid #b9b9b9;
color: #d5d5d5;
}
In the browser’s programming mode, I can manually un-check the border definition in “inline style”, and my button looks correct using my class CSS.
By the way, I realize that I can use the !important modifier on the CSS, but there must be a way to make SmartGWT stop overriding without it.
The SmartGWT version is 4.0.5.
The GWT version is 2.7.0.

How to override the pager default top and bottom margins

It would appear that that bootstrap puts a 10px margin on the top and bottom of the pager and I would like to cut that down to 2px and also make the height of the pager a bit smaller. I'm using the code from the xsnippets.openNTF as follows:
<xp:pager partialRefresh="true" id="pager1" for="repeat1"
panelPosition="left" styleClass="bootstrapPager">
<xp:pagerControl type="Previous" id="pagerControl1"
styleClass="bootstrapPagerPrevious">
<xp:this.value><![CDATA[«]]></xp:this.value>
</xp:pagerControl>
<xp:pagerControl type="Group" id="pagerControl2"
styleClass="bootstrapPagerMiddle">
</xp:pagerControl>
<xp:pagerControl type="Next" id="pagerControl3"
styleClass="bootstrapPagerNext">
<xp:this.value><![CDATA[»]]></xp:this.value>
</xp:pagerControl>
</xp:pager>
as suggested I created a new css and copied the css from the xsnippets into it and applied it to the page however I don't think that should be necessary with bootstrap built in so I removed the css. The pager works the same either way. So I want to over-ride the bootstrapPager class and change the margins.
I created a new css called it myBootstrap.css and added this block
.bootstrapPager {
display: inline-block;
padding-left: 0;
border-radius: 4px;
margin-left: 10px;
margin-bottom: 2px;
margin-top: 2px;
line-height: 1.42857;
}
and changed the top and bottom margins to 2px. added the css as a resource but the pager margins do not appear to have changed. Maybe there are some other settings that need changing. As I read it this class should override the main bootstrap.css.
EDIT
If I set disable Theme to true then it appears to remove the margins, but then it also removes all of the additional styling and that is no good either.
Here is what the pager looks like (not connected to the repeat yet but that should not matter. The major issue is the amount of vertical space that it consumes. When I inspect the element in Chrome it looks very much like it is getting the values from the main bootstrap css.
Bill,
Not sure this will work, but please try adding !important to your CSS selector. This has worked for me in the past. In my case it was OneUI, but the concept is the same. This assumes that the style is being applied, but is overwritten.
.bootstrapPager {
display: inline-block;
padding-left: 0;
border-radius: 4px;
margin-left: 10px;
margin-bottom: 2px !important;
margin-top: 2px !important;
line-height: 1.42857;
}
For more info, I wrote a blog post on this subject last year when I was having a similar problem: http://notesspeak.blogspot.com/2014/10/quick-tip-forcing-css-override.html
Note: I have never had much luck ever trying to us the "disable theme" feature.

How to set select box height in asp.net for DropDownCheckBoxes

I am unable to set Select box height for DropDownCheckBoxes in asp.net. I was able to set SelectBoxWidth, DropDownBoxBoxWidth, DropDownBoxBoxHeight.
I even tried adding SelectBoxCssClass but not working. First image is my current output. I am trying to get output as in second image
Any help appreciated
<asp:DropDownCheckBoxes ID="DdlProject" runat="server" OnTextChanged="DdlProject_TextChanged"
AddJQueryReference="true" AutoPostBack="true" CssClass="dd_chk_select" OnSelectedIndexChanged="DdlProject_SelectedIndexChanged" >
<Style SelectBoxWidth="120" DropDownBoxBoxWidth="120" DropDownBoxBoxHeight="120" DropDownBoxCssClass="btn-default dropdown-toggle" SelectBoxCssClass="btn-default dropdown-toggle dd_chk_select"/>
<Texts SelectBoxCaption="Select Project" />
</asp:DropDownCheckBoxes>
.dd_chk_select {
height: 30px;
text-align: center;
border-radius: 5px;
}
in your style try setting the tag as important
.dd_chk_select {
height: 100px !important;
text-align: center;
border-radius: 5px;
}
You said it worked, this means that your height style was being overwritten somewhere.

CSS Class Property not overwriting ASP

I'm having an issue where I can't get the summary of a redgex to format how I want.
I have put the css classes within the same aspx file as the redgex summary and marked them as important. However still when I run it, it's not being used.
Update
Within Chrome's inspect element it's saying that the redgex summary style is red. The HedderText comes up red, it seems to be the list items that aren't following suit but I don't know why they're not overriding the default.
Any ideas?
Chrome showing it's not being used but don't know why:
CSS:
.valError {
color:red !important;
}
.validation_summary {
color:red !important;
}
ASP Redgex Summary:
<asp:ValidationSummary ID="ValidationSummary1"
runat="server"
ShowMessageBox="false"
ShowSummary="true"
ValidationGroup="v1"
ForeColor="Red"
DisplayMode="BulletList"
CssClass="valError"
HeaderText="<span>The below requires attention.</span>"/>
Without any styling applied, ValidationSummary renders as a boring list with error messages.
However, it’s easy to pretty it up with some CSS since it’s nothing more than a div with an unordered list inside.So you have to define in your example and the class .valError ul
Let's see it with an example:
<asp:ValidationSummary runat="server"
DisplayMode="BulletList"
CssClass="valError" />
Next, put it in a box with a red border
.valError{
border: 2px solid red;
color: red;
margin: 5px 0px;
padding: 15px;
}
Let's say we want padding and margins on the error list and move it to the right
.valError ul {
margin: 0;
padding: 0;
margin-left: 80px;
list-style: square;
}
Hope this helps!

Sliding doors CSS, button tags and IE8

I'm working on a project to upgrade a system to use the button tag rather than regular submit buttons. For the formatting of the buttons, I have the following CSS classes:
button::-moz-focus-inner {
border: none; /* overrides extra padding in Firefox */
}
button {
background: transparent url('images/greenrightbutton.png') no-repeat scroll top right;
color: #FFFFFF;
display: block;
font: normal 12px arial, sans-serif;
height: 25px;
padding-right: 8px; /* sliding doors padding */
padding-top: 0px;
padding-bottom: 0px;
padding-left: 0px;
margin: 0px;
text-decoration: none;
border: 0px;
overflow: visible;
}
#loginbox button {
float: right;
}
button span {
background: transparent url('images/greenleftbutton.png') no-repeat top left;
display: block;
line-height: 18px;
padding: 4px 5px 5px 12px;
margin: 0px;
border: 0px;
}
They work absolutely perfectly in every browser except IE8.
In IE8, the buttons work in most places, but then I find a page where the two background images don't quite line up and no amount of tweaking padding, line spacing etc fixes it.
Does anyone know why this might be the case?
Demo page: http://test6.placement.co.uk/demo/test.asp
---Update---
After some fairly extensive testing and trying things, I've now got a pretty fair idea of what's causing the problem in page 1, but no idea how to fix it, while another page with the same issue has a completely different cause (which I haven't found) but where I HAVE stumbled on a fix...
The problem on the first page appears to relate to a ul entered further up the page. Take that out and everything behaves - unfortunately, that's not an option as the ul is part of user-entered content, so I'm scratching my head about that. Particularly given...
Page 2 has no uls to cause an issue, but randomly sticking two break tags in just before my button code resolves the problem.
Naturally, THAT fix doesn't work on page 1.
I'm just about ready to give in and find some alternative way of rendering these buttons, because whatever the actual problem is, it's clearly so deep in either my CSS or my basic HTML that I'm probably never going to find it.
I don't see any difference between IE8 and other browser. Could you pleas mention bit more clear what you want to do?

Resources