I want to display the phone number like this (999) 999-9999 I thought the css class would do this but it doesn't
<td>#Html.Encode(Model.PhoneModel.PhoneNumber)</td>.
I tried this, but it doesn't work
#String.Format("{0:(###) ###-####}",Model.PhoneModel.PhoneNumber.ToString())
I got this to work, but I don't like the fact that it's regrex.
#Regex.Replace(Model.PhoneModel.PhoneNumber, #"(\d{3})(\d{3})(\d{4})", "($1) $2-$3")
You may want to look at changing how you are outputting the values. Consider this article from Phil Haack.
http://haacked.com/archive/2010/04/28/replacing-html-encode.aspx
EDIT:
To address your edit of formatting as a phone number reference this thread:
How to format a string as a telephone number in C#
String.Format("{0:(###) ###-####}", 8005551212);
There's not much point in spending too much effort on formatting phone numbers, when others have done all the work for you. Check out http://code.google.com/p/libphonenumber/ for a library which will format numbers (and convert them back to a standard format) for you. It's also available on nuget as libphonenumber-csharp.
Related
I've read many pages that point out that many office applications allow for this by typing the code followed by Alt + X, but frequently, I want to insert a symbol when I'm not in one of those applications. Is there a universal way to achieve this?
The character map is useless, unless you have time to manually search through all the characters available.
I posted the question at Super User, and basically, the response I got there was to use Alt codes for the symbols. However, I discovered that, on the whole, these only work for the first 256 Alt codes. So basically, the answer to my question is "No, there's not a good way."
Greetings,
I have been developing site that uses globalization in asp.net(well,actually it's not globalization) :)
What I want to do is i want to show my website in multiple languages(fixed-: English,Gurmuki and Shahmukhi (Indic languages)).
To show these markup on screen i have done mapping..for example
Char Unicode Shahmukhi-Char Unicode garmukhi-char Unicode
A 65 character unicode Character of unicode of
of Shahmukhi of shahmukhi garmukhi garmukhi
I have created a demo with jQuery and do mapping as above for each character replacement..
Is there another better way to do so in ASP.net c#.
Let me know if you find uncomfortable with the information i have provided.
Important thing, I don't want to use already made components such as google Translation or other third party.I am willing to develop on my own..just need the way to do so.
Thank you and best regards.
My users despise the iPhone native date/datetime pickers (spinning wheels). I need to come up with another solution such as a custom UITableViewCell that allows direct input or a UIAlertView that is customized for input similar to the way Android handles date and time input. I'll obviously need to validate the input as they input it to ensure it is a valid date and time input, as I'm using MonoTouch I suppose I'll use RegEx to validate.
Before I do all this work I'm looking for any feedback from others that may have tried this or references to other implementations so I can learn from someone that's already created a system such as this.
What suggestions do you have for handling date/time input on an iPhone/iPad app that does NOT use the native UIDateTimePicker?
Thank you.
I ported/created a Calendar controller that works pretty much like the calendar app. One previous app that I worked on used it and the users really liked it: https://github.com/escoz/monotouch-controls/blob/master/UICatalog/CalendarMonthViewController.cs
That doesn't address time input, but it might be worthy taking a look.
#test is the selector for id="test"
.test is the selector for class="test"
but how do you remember which way round they are (eg not .=id)
Well, in truth these things are so common that most people don't need mnemonics to remember them, but here's something I came up with, if it helps:
In terms of a filename a . and then an extension denotes a type of thing. There can be many different things of this type. With CSS, using classes you can denote a single style for many elements of the same type.
In terms of a URL, a # denotes an anchor link to a specific spot in the document. It refers to one location only. With CSS, using IDs you denote a single style for a single specific element.
If a police officer catches you with "hash," he will ask to see your ID. If not you get to stay classy. It's really dumb, but that's how I remember.
CallerID shows a phone #.
Periods are round like pearls, and-- Pearls are classy.
(P.S.: What's with all the "you learn differently than me, so you suck" comments? Goodness. Repetition is OK for me, but if I can visualize something I pick things up more quickly. In fact, the weirder something is the easier it is to memorize!)
I learned it the same way I learned that quotes (rather than parentheses) are used for attributes' values — by typing them a couple of times.
If you or someone you know gets tripped up by # vs ., though, consider that many programming languages use a . to access the members of an class-typed object.
I see I'm a day late (and maybe a dollar short), but I had the same problem in the early days and the following helped:
for the dot (.) as the selector for Class, I remembered it as: "My class always starts on the dot, not a minute early or late."
for the number sign (#) for ID, I just reminded myself that an ID(entification) card is incomplete without its number.
Spend lots of time writing CSS. When you've got it wrong enough times, your brain will give in and retain it.
I'm looking to write a function to convert my server-side datetimes into my user interface datetimes, and I haven't decided on a format for either. Ideally, I'd like my function to take one standard datetime format, and return another standard datetime format.
Is there a cheat sheet, web site, or a spreadsheet that visually shows the difference between many standard date formats side by side? I'm looking for something like the "localized notations" documentation for PHP's compound date and time formats, only more comprehensive.
Are there any standards that are designed for presentation to end users - something like "January 4th, 1983 6:34 PM"?
Use and store dates in a simple, unambigous format like ISO-8601.
Rely on operating system support to convert these ISO dates into a nice localized display format. Otherwise you are just duplicating (*) the OS.
(*) : and probably "duplicating badly" because MS and Apple have far more experience and resources than you.
Have you looked at the Wikipedia article on ISO-8601? I usually try to use one of those formats when outputting dates. Additionally, the link in that article to RFC 3339 has some examples. I'm not sure if these fit your side-by-side desire, but they're a start. You might find Wikipedia's Date and time notation by country useful in that regard.