in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

Sezai's MOSS 2007 blog

stuff about Microsoft Office SharePoint Server 2007, Windows SharePoint Services 3.0, Web Content Management, MCMS to MOSS 2007 Public Internet Website Migration

SPContext.Current.FormContext

THIS BLOG HAS MOVED !!!!

 THE UPDATED POST CAN BE FOUND HERE - http://sharepoint-sezai-moss-2007.blogspot.com/2008/02/spcontextcurrentformcontext.html

 

 

 

 

SPContext.Current.FormContext is my new best friend !

http://msdn2.microsoft.com/en-us/library/microsoft.sharepoint.spformcontext_members.aspx

 

FormContext has this super Method 

       1. SetFormMode Use it to change the current SPControlMode (haven't tried this out)

 

FormContext has two awesome Properties 

       1. FieldControlCollection - Get a collection of the Field Controls.

       2. FormMode - Get the Current SPControlMode

 

What is SPControlMode?

http://msdn2.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.spcontrolmode.aspx

Editing content in a MOSS Publishing Site is done “in context” ie. You navigate to a page, and “Edit” the page, after which the page "mode" switches and you are presented with data entry controls that let you enter data into page fields.

 

So a Page can be in different modes, very similar in concept to how MCMS 2002 functions.

 

So we need a nice way to determine the “SPControlMode” programmatically in custom code so we can control rendering (do cool stuff) when in different modes.

 

The SPControlMode enumeration contains these values -

Display, Edit, Invalid and New 

 

Some example CODE that makes use of FormContext.FormMode -

' If Me not in Display Mode, Hide Me

If (SPContext.Current.FormContext.FormMode <> Microsoft.SharePoint.WebControls.SPControlMode.Display) Then

      Me.Visible = False

End If

 

 

 

THIS BLOG HAS MOVED !!!!

 THE UPDATED POST CAN BE FOUND HERE - http://sharepoint-sezai-moss-2007.blogspot.com/2008/02/spcontextcurrentformcontext.html

Published Aug 29 2007, 01:03 PM by sezai
Filed under:

Comments

 

SPSherm.MyBlog said:

Argh, Sezai beat me to this post about SPFormContext and SPControlMode by a few hours! I have to admit

August 29, 2007 5:45 PM
 

Sezai said:

Nice write up SPSherm. You also discovered this the exact same way as me.

First hunt through the Class reference, until you hit a brick wall, then fire up Reflector and see what Microsoft's code is doing.

A sure fire way you can learn how to code in SharePoint is by running Reflector on Microsoft's SharePoint Assemblies to see how they do it.

August 30, 2007 1:35 AM
 

SharePoint 2007 link love 08-30-2007 at Virtual Generations said:

Pingback from  SharePoint 2007 link love 08-30-2007 at  Virtual Generations

August 30, 2007 1:40 AM
 

Blogger Loser » Blog Archive » SPFormContext said:

Pingback from  Blogger Loser  &raquo; Blog Archive   &raquo; SPFormContext

August 30, 2007 4:04 AM
 

TrackBack said:

August 30, 2007 10:27 AM
 

Links (8/30/2007) « Steve Pietrek’s SharePoint Stuff said:

Pingback from  Links (8/30/2007) &laquo; Steve Pietrek&#8217;s SharePoint Stuff

August 30, 2007 8:01 PM
 

Blogger Loser » Creating a Standards Compliant MOSS 2007 WCM Public Internet Website With Low Page Weight said:

Pingback from  Blogger Loser &raquo; Creating a Standards Compliant MOSS 2007 WCM Public Internet Website With Low Page Weight

October 5, 2007 11:41 AM
 

On the MOSS Road said:

While I developing a webpart for retrieving data within the site I wanna to give the administrator the...

November 19, 2007 6:57 AM
 

vinoth said:

Hi ,

    I have using spcontext code to change display mode to edit mode programatically but it wont work,please  explain how to change display to edit mode programatically

Thanks

Vinoth

January 31, 2008 3:32 AM
 

Sezai's MOSS 2007 blog said:

THIS BLOG HAS MOVED !!! THE UPDATED POST CAN BE FOUND HERE - sharepoint-sezai-moss-2007.blogspot

February 4, 2008 8:08 AM
 

Valium. said:

Valium.

July 16, 2008 8:41 PM

Leave a Comment

(required )  
(optional )
(required )  
Add

Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts