Saturday, May 23, 2015

EPiServer - Check Composer Property Safe



God way of fetching this Epi-Property from Composer without null exception. Because it will always be null before it's created manually.

 public string SetLinkToTab
     {  
       get  
       {  // only tests the 2nd side if the 1st side is true.  
         if (ContentFunctionData.Property["LinkInTab"] != null && 
             ContentFunctionData.Property["LinkInTab"].ToString() == "True")  
         {  
             return "target=\"_blank\"";  
         }  
         return string.Empty;  
       }  

No comments:

Post a Comment