MVC2 Quote handling / escaping within a style attribute - asp.net-mvc-2

I have no idea how to handle this code within a style attribute. How do I correctly code this markup or properly escape it? I could use a string.format and emit the entire div but that seems like an awkward solution.
(I figured all those slant brackets would pose an issue in this posting so I am including an image.)

I see this all the time in my editor as well, for some reason, it doesn't color the attributes properly sometimes in CSS and JS. However, the attribute that you are spitting out will should still perform like you are expecting.

Related

Python class/method comment and intellisense

I have seen that the comments I write at the top of my Python methods and and classes is the same text that pops up when I am using them in my code. I have also seen that some formatting hints can be made in the comments, and that will translate into pretty rendering in the popup text (for instance, putting a bunch of "-"'s under a heading makes the font bigger and bolder). What other formatting is there and what are the hints? Specifically, is there "code" formatting that renders in monospace? I like to put code samples in my comments sometimes and that would look great.
Finally, does this all have a name? I tried googling what I was trying to do and it was hard because I didn't know what it was called.

GitHub Gist CSS

I've embedded a GitHub Gist in a website for the first time, and am having some issues with how it appears. It seems like something in my Hugo theme's CSS is adding space above line 1 and below line 13.
The problematic display can be seen here.
Anyone have thoughts on how I could remove that space? I've never see a Gist render like this before for, nor can I find any questions on here that get at what I am seeing.
Thanks for your help!
gist-embed adds a class of data to the table container. It is used to customize the look of the embedded gist. Adjust your CSS selectors to fix the problem. I am sure you are inadvertently styling the data class directly, when in actuality you want to style a compound selector article.data.
Revisit your CSS code and adjust your selectors to reflect what you desire.

Why suddenly some things have disappeared from the body section?

I've been working on a website and from time to time some elements are disappearing from the document. I've figured out that it's because in CSS document the early lines are not fully commented. I would like to ask why if even such a tiny thing like Skeleton's default version text is not fully commented or some of the classes or id's don't have a closing bracket then the whole website has layout problems. What skeleton's version has to do with page's body color ? This is really confusing.
Here is the HTML and CSS :
http://codepen.io/anon/pen/vIchA
I would be glad with any help. Yours truly,
D.
Browsers have to guess how to render bad code. Sometimes they will guess and render it correctly, other times it will look weird.
Different browsers are likely to render it differently (though error handling standards are improving)
In this case, your demo lacks a "/" at the start, which means it is trying to render the comments as css. The comments are not css, so it gets confused and does the best it can.
A quick way to find any bugs in the css is to use this:
http://jigsaw.w3.org/css-validator/

Copying the background color of an HTML element

I'd like to set the background color of an HTML element to the background color of another HTML element. This needs to happen at runtime using Javascript. I tried the following but it fails silently (the background color remains unaltered):
DOM.setElementProperty(element, "backgroundColor", "document.getElementById('country').style.backgroundColor");
Any ideas?
This is untested, but I would try
element.getStyle().setBackgroundColor(DOM.getElementById("country").getStyle().getBackgroundColor());
If you happen to be using a JS framework (jQuery, MooTools, etc), it should be as simple as something like (all code untested):
$("div2").attr("background") = $("div1").attr("background")
I normally just run with a framework (because I'm already using it elsewhere), but basic JavaScript should also be pretty simple as well, something along the lines of:
getElementByID("div2").setAttribute('background') = getElementByID("div1").getAttribute('background')
or
getElementByID("div2").Attribute('background') = getElementByID("div1").Attribute('background')
One thing I noticed in a quick reference search, though, is that the basic JavaScript method isn't consistent across browsers (IE seems to be quirky). Just something to keep in mind on that front.

GWT: creating a text widget for highly customized data entry

I'm trying to implement a kind of "guided typing" widget for data entry, in which the user's text entry is highly controlled and filtered. When the user types a particular character I need to intercept and filter it before displaying it in the widget. Imagine if
you will, a Unix shell embedded as a webapp; that's the kind of thing I'm trying to implement. I've tried two approaches.
In the first, I extend a TextArea, and add a KeyPressHandler to filter the characters. This works, but the browser-provided spelling correction is totally inappropriate, and I don't see how to turn it off. I've tried:
DOM.setElementProperty(textArea.getElement(),
"spellcheck", "false");
But that seems to have no effect- I still get the red underlines over
"typos".
In the second approach I use a FocusWidget to get KeyPress events, and a separate Label or HTML widget to present the filtered characters back to the user. This avoids the spelling correction issue, but since the FocusWidget is not a TextArea, the browser tends to intercept certain typed characters for internal use; e.g. FireFox will use the "/" character to begin a "Quick Find" on the page, and hitting Backspace will load the previous web page.
Is there a better way to accomplish what I'm trying to do?
You might just be able to use event.preventDefault() on your keypress events to avoid these browser behaviors. Otherwise, maybe a hybrid of the two approaches? Have a hidden TextArea with focus, accepting key events, and then post the typed characters to a separate Label.
There is no specific GWT method on TextBox for this, but this simple line of
GWT code fixes the problem for Chrome (for other browsers, YMMV - it may depend upon how completely they implement HTML5) by setting an attribute on the underlying input element:
myTextBox.getElement().setAttribute("spellCheck", "false");
Perhaps this attribute is a relatively new feature.