.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Home >> Articles >> SharePoint >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Hide Columns In SharePoint List On New, Edit And Disp Forms

Posted By:Sunil Yadav       Posted Date: May 26, 2010    Points: 10    Category: SharePoint    URL: http://www.dotnetspark.com  

I this article i am going to sho how we can hide Columns In SharePoint list on new, edit and disp forms.

There are situation in which we only need to show some column when creating New Item,Editing Item or Displaying Item.
Following are the way to do that..

Using C# Code

SPSite site = new SPSite("http://mossserver/");
SPWeb web = site.OpenWeb();
SPList selectedList = web.Lists["Pentest Report"];
selectedList.Fields["Affected Url"].ReadOnlyField = true;
selectedList.Fields["Affected Url"].Update();
selectedList.Fields["Description"].ReadOnlyField = true;

Using powershell

function HideFormField([string]$url, [string]$List, [string]$Field) {

  $SPSite = New-Object Microsoft.SharePoint.SPSite($url)
  $OpenWeb = $SPSite.OpenWeb()
  $OpenList = $OpenWeb.Lists[$List]
  $OpenField = $OpenList.Fields[$Field]
  $OpenField.ShowInNewForm = $False
  $OpenField.ShowInEditForm = $False
You can call it in following manner.

HideFormField -url http://mossserver -List "My Task" -Field "Title"

Using JavaScript

A simple javascript function ca do all you work.You just need to find the control and apply a style with display property to 'None'.


For more info follow the link below..


 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend