MOSS 2007

How to hide a column of SharePoint list in different mode (Add / Edit / Display Mode)?

Posted on Updated on

Most of the time we have requirement like that this field should be shown only in new mode or it should not be shown only in Edit mode not in new mode.

We can hide it in view by not to show in grid view but what to do if you do not want to see that field in Dispforms.aspx?

Here is the way how to do that.
Option: 1

SPSite site = new SPSite(”http://Server:3000/”);
SPWeb web = site.OpenWeb();
web.AllowUnsafeUpdates = true;
SPList list = web.Lists[”Sample”];
SPField objField = list.Fields[”Sample1″];
objField.ShowInNewForm = true;
objField.ShowInDisplayForm = false;
objField.ShowInEditForm = true;

Option: 2
List Definition
You can hide column appearing in New/Edit/View/ form by creating custom list defination for the list.

For creating custom list defination you can refer following MSDN link:

Now to hide a column from New/Edit/View/ form, you need to update content types of your list schema. Following is steps to do this (Assuming you have created custom list defination, following the steps mentioned in above URL):
1. Open schema.xml from your custom feature folder
2. Locate Content Types XML node, under that locates the Field which you want to hide from Edit form, set the ShowInEditForm value to FALSE.

Following example hides the Title column of custom list appearing in Edit form:

<FieldRef ID=”{fa564e0f-0c70-4ab9-b863-0177e6ddd247}” Name=”Title” Required=”TRUE” ShowInNewForm=”TRUE” ShowInEditForm=”FALSE” />


SharePoint Site Template Size

Posted on Updated on

When you turn an existing site into a template and include the content, there is a size limit of 10 Mb by default. If you site content is greater than this, a site template will not be created.
You can change this maximum size using an stsadm command on the SharePoint server.

stsadm -o setproperty -propertyname max-template-document-size -propertyvalue  size_in_bytes
Where size can be up to 500Mb (524288000 bytes)

SharePoint List Form Validation

Posted on Updated on

You Can Use “PreSaveAction()” Function to Execute any JavaScript Code in New or Edit Forms. When Pressing OK button this Function will be Executed First

You Can Use this Function For Validation without PostBack

Add Your JavaScript Code Here Then Return True Or False

return false; // Cancel the item save process

return true; // OK to proceed with the save item