Formatting address of different types

Posted by mickyjtwin on Stack Overflow See other posts from Stack Overflow or by mickyjtwin
Published on 2010-04-01T03:48:26Z Indexed on 2010/04/01 3:53 UTC
Read the original article Hit count: 355

Filed under:
|

I have various classes which all contain address details, i.e. AddressLine1, AddressLine2, AddressLine3, Suburb, Town, etc.

On the front end, I need to format the address in a particular way, i.e.

AddressLine1<br />
AddressLine2<br />
Suburb State Postcode

If AddressLine2 does not exist or empty, don't show it. Quite straight-forward. I am trying to determine the best way to show this info. At the moment, the Address property of each class calls a FormatAddress method which writes out the html string. This exists as a method of the class. My opinion is that any formatting should exist from the front-end control i.e. ascx etc. However, if these DetailClasses need to format the same address info, what would be the best option, also making it easier to maintain?

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET