Home RSS 2.0 ATOM 1.0  CDF  
 
CodeSegment - Carlos Segura Sanz (blog)
 

Some users of csegRollUp2 ask to me how to get the complete list of fields for a list, remember that you can use the internal names with csegRollUp. Now you can use csegScript to show all fields and types of any list.

Change the red code with the name of your list, and put the webpart in the site where the list is stored. 

Begin Script Code

   1:imports Microsoft.SharePoint
   2:imports Microsoft.SharePoint.Utilities
   3:imports Microsoft.SharePoint.WebPartPages
   4:imports Microsoft.SharePoint.WebControls
   5:imports System.Web.UI
   6:Module Script
   7:Public Sub Main()
   8:Dim site As SPSite = SPControl.GetContextSite(System.Web.HttpContext.Current)
   9:Dim allSites As SPWebCollection = site.AllWebs
  10:Dim subSite As SPWeb = allSites(0)
  11:Dim list as SPList = subSite.Lists("Anuncios")
  12:Dim field As SPField
  13:output.WriteLine("<table width='100%'><tr><td>Name</td><td>Description</td><td>InternalName</td><td>Type</td></tr>")
  14:For Each field in list.Fields
  15:output.WriteLine("<tr><td>"+SPEncode.HtmlEncode(field.Title)+"</td><td>"+SPEncode.HtmlEncode(field.Description)+"</td><td>"+SPEncode.HtmlEncode(field.InternalName)+"</td><td>"+SPEncode.HtmlEncode(field.TypeAsString)+"</td></tr>")
  16:Next field
  17:output.WriteLine("</table>")
  18:End Sub
  19:End Module
End Script Code

Also, some users ask to me about remove the copyright in the bottom of webpart, I think that csegScript is a tool for developpers and is not thought, for end users.And in a future I will open the code.

Note: If you want to share your small tricks, suggest improvements with csegScript, csegRollUp or others webparts please uses the forum or comments. I always respond.

(the cut and paste code is in the forum :-) )
 

Comments are closed.

Copyright © 2009 Carlos Segura. All rights reserved.