#VALUE Error

Feb 9, 2010 at 4:50 AM

There are some actions, if done on the page, instead of the content value, #VALUE gets displayed. I see that this has been fixed in version 3.0.

I have very small time, can you suggest what is the fix for this. I cannot take the new version and compare because I have done lot of changes in names etc etc.

It will be really helpful  if you can suggest the fix done for this issue.

Thanks in Advance.

Coordinator
Feb 9, 2010 at 5:26 AM

I think I changed some thing in FieldViewer.cs. I guess the easiest way is to grab the latest project and only deploy CompleteSharepoint.NET.Web.DLL into GAC and all will be good (unless you changed names, etc in that project).

  #region "Class Variables"
        private string fieldName;
        private string fieldDisplayName;
        private Literal fieldValueLiteral;
        private BaseFieldControl customFieldControl;
        private bool showOnlyInEdit;
        private Repositories.ISiteRepository siteRepository;
        private Services.ISiteService siteService;
        #endregion

        #region "Properties"
        public string FieldName
        {
            set { this.fieldName = value; }
            get { return this.fieldName; }
        }

        public string FieldDisplayName
        {
            set { this.fieldDisplayName = value; }
        }

        public object FieldValue
        {
            get
            {
                if (SPContext.Current.FormContext.FormMode == Microsoft.SharePoint.WebControls.SPControlMode.Edit)
                {
                    if (this.customFieldControl.Field.Type == SPFieldType.DateTime)
                        return ((Calendar)this.Controls[0]).SelectedDate;
                    else
                        return this.customFieldControl.Value;
                }

                return null;
            }
        }

        public bool ShowOnlyInEdit
        {
            set { this.showOnlyInEdit = value; }
        }
        #endregion

        #region "Event Handlers"
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            this.fieldValueLiteral = new Literal();
            this.siteRepository = Repositories.RepositoriesFactory.GetSiteRepository();
            this.siteService = Services.ServicesFactory.GetSiteService();
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            // Init field value literal only on Display mode.
            if (SPContext.Current.FormContext.FormMode == Microsoft.SharePoint.WebControls.SPControlMode.Display && !Page.IsPostBack)
            {
                if (!this.showOnlyInEdit)
                {
                    this.fieldValueLiteral.Text = this.siteService.GetPublishingFieldValue(this.fieldName);
                    this.Controls.Add(this.fieldValueLiteral);
                }
            }
            else if (SPContext.Current.FormContext.FormMode != Microsoft.SharePoint.WebControls.SPControlMode.Display && Page.IsPostBack)
            {
                this.customFieldControl = this.siteService.GetPublishingFieldControl(this.fieldDisplayName);

                if (customFieldControl != null)
                {
                    if (this.customFieldControl.Field.Type == SPFieldType.DateTime)
                    {
                        this.AddCalendarControl(this.customFieldControl);
                    }
                    else
                        this.Controls.Add(customFieldControl);
                }
            }
        }
        #endregion

        #region "Methods"
        /// <summary>
        /// Add calendar control as OOTB calendar field control doesn't work properly.
        /// </summary>
        private void AddCalendarControl(BaseFieldControl fieldControl)
        {
            Calendar calendar = new Calendar();
            calendar.ID = "cal" + fieldControl.Field.Title;

            object value = fieldControl.ListItemFieldValue;

            if(value != null)
                calendar.SelectedDate = (DateTime)value;           

            this.Controls.Add(calendar);
        }

        protected override void Render(HtmlTextWriter writer)
        {
            base.Render(writer);
        }
        #endregion

 

Feb 9, 2010 at 5:28 AM

Thanks a lot.

I just came to the same code while debugging. Will try this and let you know.

Thanks Again.

Feb 9, 2010 at 6:18 AM
Edited Feb 9, 2010 at 9:44 AM

Your suggested change did not work for me.

Though, I am trying out more. Do you have any more suggestions? I cannot use the CompleteSharepoint.NET.Web.DLL because there are lot of changes starting form SNK. :)

Thanks!

Coordinator
Feb 9, 2010 at 6:24 AM

The easiest way will be to replace the .Web.DLL in GAC temporarily with the latest one mate.

What has changed in the latest version is only on that project anyway and the CORE project is pretty much used only to deploy the DLL.

 

Thanks,
Tommy