Hide a custom field of type SharePoint in edit and create mode
I am trying to create a custom field type in SharePoint.
This control has a value set based on another field in the same list. Because of this requirement, this field should only appear in display mode and not in edit or create mode.
How can this be ensured?
If I just code the ASCX control to not display a field, that field appears in that mode in edit and create mode.
alt text http://www.mannsoftware.com/blog/Lists/Photos/121308_0204_CrossSiteLo6.png
a source to share
Typically, you set the SPField.ReadOnlyField property to True to achieve the desired behavior for any field. (Don't forget to SPField.Update accordingly!) I believe the CAML attribute equivalent for list definitions.
However, in your BaseFieldControl-based control class, you can simply override the RenderFieldForInput () method and not call the base implementation to ensure that nothing is displayed during creation or editing. However, this will still display the field table row on the form, which is probably not what you want. To provide the desired behavior, use ReadOnlyField and override Update () in the SPField class (not in field mode) to always be True.
a source to share
Take a look at this blog post. I think this will give you some ideas. The concept uses different mode based rendering patterns.
http://sharepoint.nailhead.net/2008/04/creating-rendering-template-that.html
a source to share
Have you tried setting the field as hidden? http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfield.hidden.aspx
Custom FORMS pages for new item and edit item (NewForm.aspx and EditForm.aspx) would be another way to achieve this.
a source to share