Stop inheriting from user agent - c#

I am trying to create a styled h4.
But my h4 keeps inheriting from some user agent?
What is this user agent.
How can I stop it from doing so. Its adding effects that I dont want.

No, the h4 element (or the h2 element, as in your screen shot) does not inherit from some user agent. Instead, it gets property values directly from a user agent stylesheet. “User agent” means a browser in practice (in principle, it could be an indexing robot, too, for example).
You can stop that simply by assigning properties in your style sheet. In fact, you have done that in your example: font-size and font-weight have been overridden. The setting display: block could be overridden e.g. by adding display: inline into your style sheet.
The margin issue is trickier, as WebKit browsers have their oddities there, and the -webkit-margin properties are shown as if they had not been overridden. But in fact they are ignored when the standard margin properties are set, as they are in your case; check out the “Metrics” pane to see this.
So you are already overriding the user agent style sheet settings. In general, a user agent style sheet could contain anything, but using a reset.css style sheet is still a wrong approach mostly. The default style sheet for HTML 4 in the CSS 2.1 spec is fairly realistic and tells you what to prepare for, e.g. display, margin, font-weight, and font-size for headings.

To stop the inheriting from the user agent (styles your web browser chooses by default for various HTML elements) madness you need to use a good CSS "reset".
Read http://meyerweb.com/eric/tools/css/reset/ for an intro into a "reset".
A list of different "resets" http://www.cssreset.com/
Also if you are using some framework like Twitter Bootstrap for example it will already have a reasonable reset included.

Related

Edit the style/template of a control created from code-behind

I'm styling WPF's Calendar control and I've reached a point in XAML where there's a grid with no elements in it, just divided by rows and columns where the day numbers are.
I've snooped and decompiled (void PopulateGrids()) and have learned that in code-behind the Calendar is creating CalendarDayButton and feeding it to the grid.
I need to change the style/theme in-order to change the colors (of those CalendarDayButton) and I'm not sure how to do that.
I've tried applying a style to all CalendarDayButton in said grid, but that didn't work.
Any suggestions?
P.S. I'd rather stay away from code-behind because what I'm working on is a style in a resource-dictionary and not a user-control.
Go to the Microsoft page for Calendar Styles and Templates, copy the style code into your resources block and make changes as needed. If you need to create additional properties for settings etc then you can do so with an attached property, that way you don't need to create a new calandar control. If you're having difficulty figuring out which parts of the template correspond to things you're seeing on-screen then put a breakpoint in your code somewhere, add the calandar control variable name to your watch window and click on the little magnifying glass to bring up the WPF visualizer...that will let you traverse the visual tree and visually see which part of the control each section is rendering.

Modifying form fields with FieldEditingControls

I’m trying to add a honey pot field to our contact us form. When I add hidden field to the form via the Kentico GUI (with conditions making it invisible) it’s not available in the source so I don’t think it will actually work. However I also tried adding the form via the GUI and trying modify the style on prerender in my form control won’t work either (Code below). It is odd as it will actually let me change the value of the field in my form control but not the styling. Is this typical of Kentico and is there a solution to trying to implement a honeypot field? I had suggested we just add more validation methods to the form, but I was told that they want the same behavior as the existing forms.
Here is the method I’m using.
((CMS.FormControls.EditingFormControl)viewBiz.BasicForm.FieldEditingControls["Pooh"]).Style.Add("display", "none");
Thanks
Under the advanced properties of the field input, you should be able to apply styles to the input. You could set display:none; there to hide it from the user, but still have it available in the source.
I'm also going to create a form control for this so that it can easily be applied to another with some validation functionality (i.e. a redirect to captcha)

How to set ASP dropdownlist to read only with css or javascript?

I have to set dropdownlost to read only. I can set enabled =false. But I cannot set font color to regular dropdown text. It will show like blur. The samething I did textbox.readonly=false. There we can see font same as regular text, no change.
The same way I want read only for dropdownlist. Is there any way we can do with CSS or javascript or jQuery ?.
Thanks in advance
There is varying browser support for this. Typically, Internet Explorer provides fewer opportunities to override the default greyed out look for disabled controls, than the other main browsers. I have struggled to do this in the past across all browsers. I would be interested to see some answers here that do this rather than my advice not to do it...
I would question why you are doing this. Your users will be used to the default look of disabled controls. It is a visual cue to them that the control is disabled. I would urge you not to disrupt this subtle visual que that people are very very used to.
Unless you can give a compelling reason to do this of course.
One way to hack this would be to not disable the dropdown list at all (taking care of the styling). Then, add an event handler to the change event that sets the dropdown back to the original value. You would have to store the original value, probably in an input of type hidden, and when you handle the change event, first check whether the value is the same as the stored value. If not, set it back. If you don't make this check you will get an infinite loop, because setting it back to the original value will call the change event again.

Microsoft ReportViewer(windows) and CSS Property

I'm using Microsoft Report Viewer in windows application and its datasource
is a custom class object. I have several Text fields and some are in different formats
(ie size of the font, underline, bold....) but several are grouped.
For these reason I would like to use a CSS (Cascading Style Sheet) class or some thing similar for formatting. (now I formatting each controls manually).
Is there a way to do this?
No, there is no way to do this. RDL, and all of the tools built around it (like ReportBuilder, BIDS, etc) have no concept of stylesheets of any kind.
The best solution is to select all the textboxes at once that you want all to be the same, then edit their properties in the property grid (in BIDS, Visual Studio or ReportBuilder). If you instead edit their properties through the property dialog, you must do it one at a time.
Probably the best you can do is to use expression parameters when you set the Font.
e.g. define report pararameter #FontSize and set default to 10
This allows you to override your default font size when you request the report by setting the report parameter.
I don't believe you can use CSS for a desktop windows application, your best bet is to look at the custom formatting for each cell of the ReportViewer

How to show compulsory fields on a windows form

How should I show users which fields are compulsory in a windows forms application.
I have considered changing the label color or maybe the background color of the text box.
I use an error provider to show a red exclamation mark next to the field, however this is only visible after they have clicked the save button.
Asterisk or icon to the side of control
Red border when required validation fails (when user tries to save)
Bold Labels
Different background color for required controls (perhaps only when user tries to save)
Use the errorprovider extension control.
This places a red cross next to the control with a tooltip message.
Yellow background would make it similar to many web forms. No idea whether there are any standards for Windows per se, though if there are I doubt they are widely used.
I would use the ErrorProvider control, possibly with a different icon to represent "required" as opposed to "in error". I would also ensure the fields start with error icon shown next to them and the icon should only disappear once data has been provided for that field.
Only doing validation/notification of missing data when the user tries to save seems way too late.
Something to consider is what users are accustomed to seeing for required fields. While not graphically spectacular, placing a simple asterisk next to required field is a very ubiquitous solution.

Categories

Resources