Postfix Label Text with Colon

Postfix label text with colon

Through CSS, you can add the colon via the after pseudo class. You can find more information about this pseudo class here.

.editor-label > label:after {
content: ": "
}

Working example: http://jsfiddle.net/fJQDZ/

Please note that the after pseudo class is not available in IE7.

Easy way to overload Html.LabelFor to add a 'suffix'?

You could do this:

@Html.LabelFor(m => m.Description,
string.Format("{0}:", Html.DisplayNameFor(m => m.Description)))

DisplayNameFor gives you just the display name for the property without the label markup, so you can use this as part of the labelText parameter in LabelFor and format it as you please. This way you still get the benefit of dynamically generated label text.

Easily wrapped up in its own helper:

public static MvcHtmlString LabelWithColonFor<TModel, TValue>(
this HtmlHelper<TModel> helper,
Expression<Func<TModel, TValue>> expression)
{
return helper.LabelFor(expression, string.Format("{0}:",
helper.DisplayNameFor(expression)));
}

Then:

@Html.LabelWithColonFor(m => m.Description)

ASP.MVC concatenation in Html.LabelFor helper or model Display Name annotation

You can use css to add the : if you give your labels a class name:

@Html.LabelFor(model => model.name, { @class = 'postfix'} )

CSS:

label.postfix:after
{
content: ":";
}

Or you can create an extension helper and call it as

@Html.LabelForPostfix(model => model.name)

Break text in different lines with \r\n

You need to convert the newline characters to HTML's <br /> element:

<div>@Html.Raw(Model.Description.Replace(Environment.NewLine, "<br />"))</div>

SelectListItem Text not being displayed

try this

public IEnumerable<SelectListItem> CountiesList;

CountiesList = from c in entities.Counties
select new SelectListItem
{
Value = c.CountyID.ToString(),
Text = c.County //the county name, nvarchar/string
};

because you shoudn't fill a SelectList with an IEnumerable<SelectListItem>. Use either SelectList or an IEnumerable<SelectListItem>, but not both.

Put constant text inside EditText which should be non-editable - Android

Did u try this method?

final EditText edt = (EditText) findViewById(R.id.editText1);

edt.setText("http://");
Selection.setSelection(edt.getText(), edt.getText().length());

edt.addTextChangedListener(new TextWatcher() {

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// TODO Auto-generated method stub

}

@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub

}

@Override
public void afterTextChanged(Editable s) {
if(!s.toString().startsWith("http://")){
edt.setText("http://");
Selection.setSelection(edt.getText(), edt.getText().length());

}

}
});

Adding suffix to labels on x-axis

Currently you are passing the values from the Clock column to be plotted on the x-axis and since these are strings, matplotlib interprets them as a categorical variable. If you are okay with this, then each of the x-ticks will be spaced equally apart regardless of their value (but we can sort the DataFrame before passing it), and then to get the desired tick labels you can take the portion of the string before the colon symbol (for example '20' from the string '20:30') and add the string ' hours ago' to that string to get '20 hours ago'. Then pass each of these strings as labels to the plt.xticks method, along with the original ticks in the Clock column.

import matplotlib.pyplot as plt
import pandas as pd

## recreate the data with times unsorted
df = pd.DataFrame({
'ID':[260,127,7,10,8],
'Time':['21 hours','21 hours','5 hours','6 hours','6 hours'],
'Clock':['20:30','20:30','12:30','11:30','11:30',]
})

df_sorted = df.sort_values(by='Clock',ascending=False)
plt.scatter(df_sorted['Clock'], df_sorted['ID'])

## avoid plotting duplicate clock ticks over itself
df_clock_ticks = df_sorted.drop_duplicates(subset='Clock')

## take the number of hours before the colon, and then add hours ago
plt.xticks(ticks=df_clock_ticks['Clock'], labels=df_clock_ticks['Clock'].str.split('\:').str[0] + ' hours ago')
plt.show()

Sample Image



Related Topics



Leave a reply



Submit