using
System;
System.Collections.Generic;
System.Linq;
System.Text;
Microsoft.SharePoint;
namespace
HideFieldInListFormRahul
{
class
Program
static
void
Main(
string
[] args)
try
Console.WriteLine(
"This tool will hide a field from list forms. It requires List Url and field URL"
);
"Please enter list URL"
String listUrl = Console.ReadLine();
"Please enter column name"
String columnName = Console.ReadLine();
"Enter 1 for EditForm, 2 for DisForm and 3 for NewForm"
String formType = Console.ReadLine();
(SPSite site =
new
SPSite(listUrl))
(SPWeb web = site.OpenWeb())
String listRel = listUrl.Substring(web.Url.Length);
SPList list = web.GetListFromUrl(listUrl);
SPField field = list.Fields[columnName];
if
(formType.Trim().Equals(
"1"
))
field.ShowInEditForm =
false
;
}
else
"2"
field.ShowInDisplayForm =
"3"
field.ShowInNewForm =
Exception ex =
Exception(
"No Proper number between 1 to 3 has been entered"
throw
ex;
field.Update();
"The execution completed.Press Enter to Exit"
Console.ReadLine();
catch
(Exception e)
Console.WriteLine(e.Message);
Console.WriteLine(e.StackTrace);
Richard Mueller edited Revision 2. Comment: Modified title casing
Richard Mueller edited Revision 1. Comment: Change tag "SPS 2010" to "SharePoint 2010"
Maheshkumar S Tiwari edited Original. Comment: Added tags ,title casing and minor edit