title: Field property is required. All field web controls require the field name to be set
body: <p>I am assigning the field name of Sitecore image control dynamically from code behind file like below:</p>
  
  <p>.ascx</p>
  
  <pre><code>&lt;sc:Image runat="server" ID="scImgRelatedArticle"&gt;&lt;/sc:Image&gt;
  </code></pre>
  
  <p>.ascx.cs</p>
  
  <pre><code>if(currentItem != null)
  { 
  Sitecore.Web.UI.WebControls.Date scDateArticleDate = e.Item.FindControl("scDateArticleDate") as Sitecore.Web.UI.WebControls.Date;
                      if (scDateArticleDate != null)
                      {
                          if (DisplayDates)
                          {
                              scDateArticleDate.Field = StartDateFieldName;
                              scDateArticleDate.Item = currentItem;
                          }
                      }
  }
  </code></pre>
  
  <p>Sometimes current Item is null i don't want to assign any field value. I dont want to display the item. But i am ending up with an error message "Field property is required. All field web controls require the field name to be set." </p>
  
  <p>Is there a way in sitecore to do this automatically if i didn't specify the scDateArticleDate.Item property.</p>