GingerSquirrel
4/6/2016 - 9:50 AM

Inline IF Statement Umbraco 7.html

<form id="sideForm" class="@(CurrentPage.DocumentTypeAlias == "pageAlias" ? "hidemobile" : "")" method="POST" action="@formAction">

<!-- If An Image Is Present Use It, Otherwise Use A Colour -->
<section class="hero hero-home text-center background-cover" style="@(selection.HasValue("backgroundImage") ? "background-image: url('"+ Umbraco.Media(selection.backgroundImage).Url +"');" : "background-color: #000000;")">


Assigning a variable
//new
    string subject = (CurrentPage.emailSubject != "") ? CurrentPage.emailSubject : "Website contact form submission";
//old
    var subject = "";
    if (CurrentPage.emailSubject != "")
    {
        subject += CurrentPage.emailSubject;
    }
    else
    {
        subject += "Website contact form submission";
    }