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
Monday, February 4, 2008
Subscribe to:
Post Comments (Atom)



1 comments:
just what I needed - thanks!
Post a Comment