protected override void CreateChildControls() { this.DisableInputFieldLabel = true; base.ControlMode = SPContext.Current.FormContext.FormMode; base.CreateChildControls(); dateField = (HTML5PublishingDateField)ItemFieldValue; if (dateField == null) { dateField = new HTML5PublishingDateField(); } DateTime pubTime = DateTime.Now; //DateTime.TryParse(ListItem[SPBuiltInFieldId.PublishedDate].ToString(), out pubTime); if (base.ControlMode == SPControlMode.Edit || base.ControlMode == SPControlMode.New) { html_date = (Time)this.TemplateContainer.FindControl("html_date"); string pattern = html_date.Pattern; html_date.IsPubDate = true; html_date.DateTime = String.Format("{0:dddd MMMM d, yyyy}", pubTime); } else { html_date = (Time)this.TemplateContainer.FindControl("html_date"); string pattern = html_date.Pattern; html_date.IsPubDate = true; html_date.DateTime = String.Format("{0:dddd, MMMM d, yyyy}", pubTime); } }
public override string GetFieldValueAsText(object value) { HTML5PublishingDateField field = (HTML5PublishingDateField)value; if (field != null) { return(field.ToString()); } return(string.Empty); }