This seems like it should be a simple thing to do, but I can't figure it out.
I have a localized resource that I'm using in two places - one as a col. header in a datagrid, and then as a descriptor beside a field when the user edits a row.
The text of the label looks like:
Text="<%$Resources:Global,keyName%>"
However, I'd like to add a trailing : to the label - except if I change the above to
Text="<%$Resources:Global,keyName%>:"
then the : is the only thing that shows up! I've tried it with simple strings, so there's nothing special about the colon char that causes this.
Surely I don't have to have 2 different resources?
Have you tried Text="<%$Resources:Global,keyName%>" + ":" ?
You'd basically be concatenating two strings. Or treat them as two strings
StringBuilder t;
t.append(<%$Resources:Global,keyName%>)
t.append(":")
Text = t;
Assuming you need to keep the : together for styling reasons, replace the label with a span:
<%=Resources.Global.keyName %>:
Well, sometimes the obvious isn't so obvious until someone else looks at it:
Text="<%$Resources:Global,keyName%>" /> :
Just move the : outside the label tag, and all is well.
Related
I am using "PHP Simple HTML DOM Parser" library and looking forward to find elements based on its text value (plaintext)
For example i need to find span element using its value "Red".
<span class="color">Red</span>
I was expecting bellow code to work but seems that it just replaces the value instead of searching it.
$brand = $html->find('span',0)->plaintext='Red';
I read Manual and also i tried to look in library code itself but was not able to find the solution, kindly advise if i am missing something or it is simply not possible to do via Simple Html DOM Parser.
P.S
Kindly note that i am aware of other ways like regex.
Using $html->find('span', 0) will find the (N)th span where in this case n is zero.
Using $html->find('span',0)->plaintext='Red'; will set the plaintext to Red
If you want to find the elements where the text is Red you could use a loop and omit the 0 to find all the spans.
For example, using innertext instead of plaintext:
$spansWithRedText = [];
foreach($html->find('span') as $element) {
if ($element->innertext === "Red") {
$spansWithRedText[] = $element;
}
}
Is there some means - short of extending the JavaFX charting base class(es) - to specify a multi-line title string?
As seen in the screenshot the title is the only element 'wanting' more space.
I had seen some references to using a newline '\n' and even a pipe character '|' in the string but they apparently do not work for the title.
I just threw this in a sample I had and it worked.
chart.setTitle("really long title...........\n.............and some more ");
Label l = (Label)chart.lookup(".chart-title");
l.setWrapText(true);
The \n sets the break point if I don't want it at the limit.
As you can see it's just a Label, the hard part is getting it.
You can also use a css file with the selector. I think it's already centered.
.chart-title{
-fx-wrap-text : true;
-fx-alignment : center;
}
I am trying to set a label in a gridview not to show a particular date if it is returned (it is because it is a default date and is not needed).
The code I have used is
<%# 'Convert.ToString(Eval("DateTaken")).Equals("01/01/1899") ? "" : Eval("DateTaken")'%>
Unfortunately, when I try and compile it the code won't run. I have tried to find an answer by research, but have not been able to do so.
It uses part of Chris's answer, but Equals does not work. Changing this to Contains does when parsing the value as year
<%# 'Convert.ToString(Eval("DateTaken")).Equals("01/01/1899") ? "" : Eval("DateTaken")'%>
This is not valid syntax as far as I am aware. You have single quotes ' wrapping your statement which is likely confusing the parser a lot. I'm not sure what you intend them to be doing but I'd suggest trying without:
<%# Convert.ToString(Eval("DateTaken")).Equals("01/01/1899") ? "" : Eval("DateTaken")%>
I can't test this but it looks like it should work.
Also for the comparison (I assumed you'd tested that elsewhere first) I suspect you may have problems with the fact that Convert.ToString likely includes a time element. Instead I would suggest specifying what string format you want to be outputted. Or even better assuming that it is a DateTime you are getting back compare it as a DateTime. Either of the following should work as a reliable comparison
(((DateTime)Eval("DateTaken")).ToString("yyyy-MM-dd")=="2014-03-05")
(((DateTime)Eval("DateTaken")).Date==new DateTime(2014,03,05))
I'm creating a html table at runtime (no probs there), and I would like to be able to format the content in the cells at runtime by passing in a format string (ie currencies, decimals, decimal places etc)
for example, i want to achieve something like this but to be able to pass in the format of the string with code as a string, ie "{0:c}" or "#,###,###"
ideally to be able to pass it into the ToString() method ( i can't do that but was wondering if there could be a clever way to achieve this?)
tblCell.Text = dt.Rows[i][j].ToString(#.##);
tblCell.Text = String.Format("{0:c}", dt.Rows[i][j])
and
tblCell.Text = String.Format("{0:#.##}", dt.Rows[i][j])
should work.
You can supply format strings to the columns in your GridView by setting the DataFormatString property of the column to something like this: “{0:d}”.
Have a look at:
http://www.cheat-sheets.org/saved-copy/msnet-formatting-strings.pdf
I always use this cheat sheet to find out things like these as the number of possibilities is simply to big to remember them all
How can one insert a Unicode string CSS into CleverCSS?
In particular, how could one produce the following CSS using CleverCSS:
li:after {
content: "\00BB \0020";
}
I've figured out CleverCSS's parsing rules, but suffice that the permutations I've thought sensible have failed, for example:
li:
content: "\\00BB \\0020" // becomes content: 'BB 0'
EDIT: My other examples and the rest of my post weren't saved. Suffice to say that I had a longer list of examples that's missing.
I'd be grateful for any thoughts and input.
Brian
EDIT: I noted that inserting the unicode was one of the problems (once you start uploading CSS with utf-8 encoding it's fine). The wrapping of quote characters is another, which I solved that with something crazy likeso:
content: "'".string() + " ".string() ».string() + "'".string()
Hope that helps someone else.
This may be silly, but why still bother with escape sequences when you can just type/paste the actual characters? "A CSS style sheet is a sequence of characters from the Universal Character Set".
That is a lot easier on the eye, and is especially useful when maintaining existing code.
Or is CleverCSS not Unicode-enabled?
In looking at the code (CleverCSS 0.1) it would appear that the partial regular expression _r_string (defined on line 414) is where you would need to start. This is used to define several other REs, including _string_re which is used in the parsing rules (line 1374). This leads us to process_string() (line 1359) which looks like it was meant to accept Unicode.
Unfortunately, hand-built parsers tend to get a bit strange and the code is not exactly swimming in comments. If you really need to do this, I would focus on process_string() and put a bunch of before/after print statements in there and see if you can understand the goes-intos and goes-outofs.
You might also try bribing the original author with beer or ??? Good luck.