Andrew Connell [MVP MOSS]
1543 Posts |  42 Articles |  4756 Comments
.NET  |  MCMS  |  SharePoint  |  Office System
SharePoint Quick Links
Article Categories
Archives
Post Categories


Add to Technorati Favorites

Ever want to provide certain field controls to your content authors when editing a page, but never have that content appear in presentation (or display) mode? No custom code needed! One of the server controls that ships with MOSS is the EditModePanel. This control, available to developers/designers in the SharePoint Designer Toolbox under SharePoint Controls / Server Controls (SharePoint), when dropped on a page layout, will only render it's contents when you're in edit mode. If someone is browsing the page in display mode, the contents aren't even rendered out.

There's a great example of this if you check out the ArticleLeft.aspx page layout included in the Publishing Portal site template. Go into the Press Release section of a site collection created using the Publishing Portal template and create a new page using the (Article Page) Article page with image on left. Notice how there is a place to select the rolloup image? When you publish the page, notice that image you selected isn't rendered. I'm sure this will come in handy to many folks.

EditModePanel

 

posted on Saturday, December 23, 2006 1:08 AM

Feedback

# re: Hiding field controls in a page layout from presentation... 1/29/2007 10:14 PM Adam
Gravatar Hi Andrew, thanks for the info as always. Is it possible to use this EditModePanel in custom list forms? I was hoping to use the same form for New/Edit/Display modes instead of having 3 files to maintain...but:
1. EditModePanel just causes an error in the designer when dragged onto a custom list form (does not recognise WebControls tags.) (RTM version.)
2. Designer does not let me save the same file as a custom form for New and Edit in Supporting Files of list.
Any way we can use the same form for these 3 uses please?
Thank you!
Adam

# re: Hiding field controls in a page layout from presentation... 1/29/2007 11:31 PM AC [MVP MCMS]
Gravatar Adam- I seriously doubt it because I believe the EditModePanel only works with PublishingPages that are in edit mode and custom list forms are not publishing pages. Sorry, I don't believe there's a way to have one file be used for the three different pages.

# re: Hiding field controls in a page layout from presentation... 1/30/2007 7:52 PM
Gravatar Hi Andrew - many thanks for your very prompt response. That makes sense, I hadn't realised this was restricted to PublishingPages.

My reason for wanting to customise lots of list forms is to work around limitation of published News, Issues etc all having to be stored in Pages library, mixing "content pages" with "site structure" pages, making them harder to surface/separate.

It looks like custom list templates may be way to go (News list, issues list etc), although this seems to cause custom page duplication (maintenance) when used across multiple sites. I'll keep investigating!
Thanks again, Adam.

# re: Hiding field controls in a page layout from presentation... 12/23/2006 3:06 AM Sahil malik
Gravatar Andrew -

Can this approach also be used to hide the top bar for anonymous view? Say for instance, I do want to allow some customization, even for anonymous views (cookie based), but I don't want that bar to appear.

SM

# re: Hiding field controls in a page layout from presentation... 12/24/2006 9:01 AM AC [MVP MCMS]
Gravatar Sahil - No... because if you use this for the top nav bar, then the only time the top nav bar would ever appear is in edit mode. In the case you mention, no one, even authenticated users (or anonymous users with the cookie), would ever see anything in the top nav bar. It would ~only~ appear in presentation/display/published mode.

# re: Hiding field controls in a page layout from presentation... 1/10/2007 12:13 PM Donna Sullivan
Gravatar It's great news that we can use the edit mode panel to show info to, say, authors, but not end users. Would you have any advice on how one would include the Date Created field in the edit mode panel and to make it display only? Near as I can tell, "Date Created" is not a site column. Therefore, I can't add it to a content type and can't figure out how to add it to the page. Any advice would be appreciated.


# re: Hiding field controls in a page layout from presentation... 1/11/2007 11:35 AM AC [MVP MCMS]
Gravatar Donna - The "Date Created" (and Created By, Modified, Modified By) fields are all hidden fields which means you can't just drag & drop them from SPD onto the page layout. However, there's nothing stopping you from creating a field control (or server control) that extracts this information out. Your server control can easily obtain a reference to the current item and pull information from that field (Created) to display in the Edit Mode Panel. But, there's nothing OOTB that you can use... going to require some custom coding.

# re: Hiding field controls in a page layout from presentation... 2/22/2007 1:29 AM Adam
Gravatar Hi Andrew, A quick update on my query from 1/30/2007. I have created content type that references a custom display form in the layouts folder....but I haven't been able to make it display anything! When creating the aspx in SPD it won't let me drag any field controls onto the page....and a custom list form control would be tied to a particular list?

Do you know of any examples of either ghosted custom list display forms or content type display forms please? Thanks! Adam

# re: Hiding field controls in a page layout from presentation... 7/10/2007 7:13 AM Manjunath
Gravatar Thanks a lot !!!

it saved lot of my time...



# re: Hiding field controls in a page layout from presentation... 8/17/2007 8:31 AM Cédric
Gravatar Hi Andrew,
Just a simple question (i'm new to sharepoint).
How to get value by object model of this hidden fields (and not hidden fields too, i think it's the same) ?
Thanks

# re: Hiding field controls in a page layout from presentation... 8/17/2007 12:23 PM AC [MVP MOSS]
Gravatar Cedric-
These fields are only hidden from rendering. You get them just like any other field: SPListItem["fieldname"].ToString()

# re: Hiding field controls in a page layout from presentation... 9/29/2007 7:00 PM Rayudu
Gravatar Hi Andrew,
I used an editmode panel on a page and when i published the page It is not allowing the Edit Page menu item enable. Do you have an Idea why it is disabling Edit Page Menu item from the Site Settings.

# re: Hiding field controls in a page layout from presentation... 9/30/2007 12:30 AM AC [MVP MOSS]
Gravatar Rayudu-
That sounds permissions related... not related to the edit mode panel.

# re: Hiding field controls in a page layout from presentation... 10/18/2007 10:11 PM ken
Gravatar awesome, thanks

# Resizing Page Layout Field Controls 6/7/2008 7:46 AM Gary
Gravatar Resizing Page Layout Field Controls

Hi, I have created a page layout which displays perfectly when rendered in IE. When it is in edit mode (when I create an new page or edit an existing one) the fields stretch very far horizontally across the browser making it quite unwieldy to work with. How do I set the size of the field controls so that I can cotrol the layout when in "edit" mode.

Also are there any resources available that describe the Tag Properties of the publishing controls?

Thanks very much
Regards
Gary


# re: Hiding field controls in a page layout from presentation... 6/7/2008 8:01 PM AC [MVP MOSS]
Gravatar Gary-
Just look them up in the SDK... the tag properties are attributes on the server control and expose public properties on the objects.

# re: Hiding field controls in a page layout from presentation... 6/30/2008 8:28 AM Rodolfo Cardoso
Gravatar Thanks, great tip....

# re: Hiding field controls in a page layout from presentation... 7/20/2008 11:42 AM Harish
Gravatar Hi,
I want to update the scheduling of a publishing page, is it possible by using custom field controls?

Many thanks,
Harish

# re: Hiding field controls in a page layout from presentation... 7/21/2008 7:22 AM AC [MVP MOSS]
Gravatar Harish-
You don't need custom... just use date fields.

# re: Hiding field controls in a page layout from presentation... 10/22/2008 9:48 PM Ram
Gravatar Hi Andrew,
Is there any way, we can restrict some controls basing on user credentials. For Example: If User1 logs and see's 10 fields and he fills up all the fields and waits for User2' approval. User2 logs in and checks whether 10 fields submitted by user1 are good and also user2 see's more fields to fill some extra information and approves. How can control display of fields according to user roles.

Thanks in Advance,

# re: Hiding field controls in a page layout from presentation... 10/22/2008 9:57 PM AC [MVP MOSS]
Gravatar Ram-
You'd have to roll your own composite control that hid stuff based on their permissions... but it's really moot. Users are granted rights on a list item, not on fields. They could easily bypass what you've setup by going straight to the item in the list circumventing everything. What you're looking for is column security which SharePoint does not provide.

# re: Hiding field controls in a page layout from presentation... 11/2/2008 11:04 PM MOSSBUDDY
Gravatar Thank you Andrew, this really helps. In case if the content of a page (this could be all field controls lets assume 10) is very long/lengthy, then how would we implement paging for the content page? i.e. lets say if we have some content of 200 lines, this could be a Field control with 100 lines and other field control with 100 lines and when they render the content will be very lengthy then how would we implement paging? As it is not necessary that one field control's content is large than other, it could be content of any control that is large so basically only 50 lines of content shld be avlbl on page-1 and then show some kind of paging to have other controls render on remaining pages. How can we do this with MOSS and WCM? Any recommendation on HTML/JSCRIPT way of paging?

# re: Hiding field controls in a page layout from presentation... 11/3/2008 8:47 AM AC [MVP MOSS]
Gravatar MOSSBUDDY-
No, I have nothing to recommend as I've never needed to do this. Whatever you do it's going to be all custom. Maybe a slick tabbed interface?

# re: Hiding field controls in a page layout from presentation... 11/27/2008 11:23 AM Jeffrey
Gravatar I have a problem with the editmodepanel. My page is composed of a editmodepanel with several fields inside, no field on my layout page is outside this editmodepanel. No matter what I do, i can't have the edit page option in the site action menu. It's kind of strange because i am a sitecollection administrator and all my other layout that are using the editmodepanel are working fine. The only difference i can see is that in the other layout where I use the edit mode panel, i have field outside the panel. What do you think I did wrong ?

# re: Hiding field controls in a page layout from presentation... 11/28/2008 8:58 AM AC [MVP MOSS]
Gravatar Jeffery-
So on a page where you use the EMP, you aren't getting Site Actions>Edit Page, but on other pages you are? that's either a permission thing or a bug...

# re: Hiding field controls in a page layout from presentation... 3/18/2009 8:31 AM Gary
Gravatar Hi Andrew, any idea how I can define my own validation error message text for field controls?

Thanks
Gary

# re: Hiding field controls in a page layout from presentation... 3/18/2009 6:40 PM AC [MVP MOSS]
Gravatar Gary-
You can use standard ASP.NET validation controls for your custom field controls. If you're talking about a field type, look to the GetValidatedString() on the field type class.

# re: Hiding field controls in a page layout from presentation... 3/23/2009 9:04 PM Jaclyn
Gravatar Hi Andrew,

I wanted to add an ASP.NET dropdownlist control in an editmodepanel for a publishing page and filter my dataformwebpart based off the value specified in the dropdown. However, I get an error in SPD when I put the ASP control in the editmodepanel and as a result, my dataformwebpart doesn't filter. Do you know any way I can get around this?

Thanks for your help in advance!

# Issue with Number Fields on Publishing Content Types 9/18/2009 2:18 PM Scott Ewing
Gravatar Hi Andrew,

Not sure where to post this question, as I've tried the MSDN groups as well with no luck. Have you ran into the issue where you can't use a number or integer field to a content type for a publishing page? You can add one to a new content type based on the Page content type, but when you create an actual page based on that content type it's not there anywhere. You can verify this by looking at the fields in the instance of the content type saved for that local pages list. Was this documented somewhere that I've missed, or is this just a huge oversight, or am I doing something wrong? I'd like to have a custom sort field, which I would like to have be a number, or I could imagine othe scenerios where a number field would be disireable.

Thanks,
- Scott

Post Feedback

Title:
Name:
Email:
(email will not be displayed)
Url:
Comments: 
Please add 3 and 1 and type the answer here:    
All Comments Are Filtered & Moderated
Unfortunately comment spammers are just too effecient and are constantly dirtying up blogs with irrelevant and unwanted comments trying to improve their standing on search engines. All comments on this blog are moderated. I do not censor comments, but I don't approve comments with vulger language or those soliciting products. Most of the time comments are approved within a few hours of being submitted with the only exception when I'm traveling.

Why are you asking for my email address?
The only reason I'm asking for your email address, which isn't required to submit a comment, is to provide a gravatar if you've created an account for yourself and associated your email address with a small image. If you have a gravatar created for the email address you submit, it will appear next to your comment. Otherwise nothing will appear.

What is a gravatar?
A gravatar is a "globally recognized avatar." You can get more information about gravatars, as well as create your own for free, at www.gravatar.com. You can also view my gravatar here.


Copyright © 2003 - 2010 Andrew Connell
Creative Commons License 
This work is licensed under a Creative Commons License
Site design by Heather Solomon.

 
 
MOSS WCM Training
Looking for MOSS 2007 WCM developer training? Look no further! I teach my 5-day hands-on and online WCM classes for developers I offer through my company: Critical Path Training.

Get more information on the WCM courses!