EPiPattern: DO & DONT with EPiServer Properties

opções binarias demo account This might be obvious stuff for most seasoned EPiServer developers but I still think it is worth blogging about because I see these dangerous mistakes whenever I do a code review of an EPiServer project.

Null values

le azioni binarie cosa offrono Remember that all EPiServer properties with an empty value never are stored in the database. If you access it from code, it will always be binäre optionen fundamentalanalyse null – not an empty string, 0 or false as you maybe expected.

straff för viagra Why null? It is by design and is very convenient if you want to check if something is not set by an editor or does not exist on this page. You just have to compare with null regardless of data type.

Example – DO & DONT

opciones binarias señales This will throw NullReferenceException if value is empty or missing:

http://vajh.net/?arabinaar=%D9%85%D8%A4%D8%B4%D8%B1-%D8%A7%D9%84%D9%81%D9%88%D8%B1%D9%83%D8%B3&118=b4 مؤشر الفوركس StringBuilder.Append accepts null objects so this is better:

opcje binarne z bonusem bez depozytu This will throw NullReferenceException if value is empty or missing:
<%= CurrentPage.Property[“MyProperty”].Value.ToString()%>

olagligt att beställa Viagra på nätet Markup will accept any type and convert to string so cast is not needed:
<%= CurrentPage [“MyProperty”] %>

Other examples with fallback

binäre optionen ohne einzahlung bonus If must have a string returned use as operator and ?? operator:
string x = [“MyProperty”] as string ?? string.Empty;

opcje binarne minimalna transakcja And for Value Type it is written like this: (thanks Henrik)
DateTime x = (DateTime)(CurrentPage[”MyProperty”] ?? DateTime.Now);
int i = (int)(CurrentPage[”MyProperty”] ?? 0);

ثنائي الخيار الغوريلا If you need a fallback in markup the?? Operator can be used:
<%= CurrentPage[“Heading”] ?? CurrentPage.PageName %>

Use Default indexer

http://dangerhardcoreteam.com/buttons/virus_29_gr.jpg الخيارات الثنائية وسطاء المشروعة Remember that there is a default indexer on PageData that returns the value, too.

fxoro com Example – DO & DONT

binaire opties kopen This expression:
<%= CurrentPage.Property[“MyProperty”].Value %>

binaere optionen …is equivalent:
<%= CurrentPage[“MyProperty”] %>

Common EPiServer Property Names

professionelle trading signale binäre optionen It is very common that Page Types in EPiServer has the following properties.

Heading (string)

binaire opties betrouwbaar Used for the h1-tag of the page. If not defined the page is coded to fall back to the PageName. (See public templates for example implementation). This makes it possible to use PageName for a shorter text in menus and the meta title-tag and have a little longer text for the actual h1-header.

MainIntro (string)

trading binario soleventiquattro ore This property is commonly used to describe a page in Teasers on other pages and in search results. It is usually also used to generate the meta description-tag which can affect the description external search engines like Google show.

There are functions in EPiServer that uses MainIntro – like PreviewText() method on PageTemplateContainer (type of Container object in EPiServer PageList, PageTree, etc). It implements a fallback if no MainIntro exists to strip MainBody of HTML and use first 400 characters.

MainBody (string)

Almost always used for the body text of an page in EPiServer.

Read more

Read more about Properties with Special Functionality in EPiServer.