Microsoft Content Management Server Resources
MCMSfaq.com
subcribe to the feed.
r.a.d.editor MCMS edition AchieveForms Lite CMS.Rapid MCMS Manager GotDotNet User Samples MondoSearch Metalogix Migration Assistant Cubik OneStopCMS IT Hit Web Author Enhancements
MCMSfaq.com Home >  Code Samples >  MCMSfaq.com Code Samples >  Extended Attachment Placeholder for MCMS 2002

Extended Attachment Placeholder for MCMS 2002

Updated: March 28th 2005.

 

Introduction

The SingleAttachmentPlaceholder Control that ships with MCMS 2002 is a great way to include links to binary files on your site. However the Presentation Mode rendering of the control, especially when using the MustUseGeneratedIcon property leaves much to be desired. This control avoids the cost of dynamic rendering of icons, allows for full transparency in icons, more precise rendering control and the addition of a target attribute to open the link in a different frame or new window.

Although the SingleAttachmentPlaceholder Control's generated icon is a GIF which includes transparency, it also includes a nasty white background for the all important 32 pixel square portion of the icon. In addition the generated icon includes either the filename, or AttachmentText property rendered in 10pt Black Arial. This can cause un-desirable display and renders the control unworkable in situations where more stylistic control is required. The following screenshot shows an example of this undesirable rendering:

Screenshot of Attachment Placeholder rendering

(Admittedly anyone using this shade of blue for their background on a real Web site probably shouldn't complain :-))

The Extended Single Attachment Placeholder Control.

To workaround these limitations we have created an extended version of the SingleAttachmentPlaceholder control, which provides a number of ways to gain more control of the Presentation Mode rendering. The control avoids the runtime cost of dynamic icon rendering by using 'local' images. These local images allow site developers to control the icons used, their location and properties. This also avoids the registry hacks associated with ensuring all icons are able to be rendered by the production server. The control allows for the links to target a different frame or new window. In Authoring Mode the control behaves exactly the same as the SingleAttachmentPlaceholder. Below are some samples of the rendering of the extended control:

Screenshot of Extended Attachment Placeholder rendering Screenshot of Extended Attachment Placeholder rendering

Implementing the sample.

To implement the sample add the Control to your Visual Studio.NET toolbox, drag onto a template, and bind to an AttachmentPlaceHolderDefinition as you would with any other placeholder control. Alternatively you can copy the class file into your own Web Control Library project for more appropriate packaging or further customisation. The control exposes the following Design Time properties:
 

Name

Type

Description

Appearance

DisplayIcon

Boolean

Determines if a file icon <img /> element and link is displayed.

LineBreak

Boolean

Include a <br /> element between the <img /> element and text only <a /> element.

LinkClass

String

CSS class to include in text only <a/> element. If Null, no class attribute is applied.

Data

IconPath*

String

Path to file type icon images. Must include trailing '/'

Target

String

Target attribute of <a/> elements for loading attachment into another window or frame. If Null, no target attribute is applied.

* Note: icon images should be named 'eapext .gif', where ext is the file extension (e.g. eapdoc.gif for Word documents. A sample icon image is provided.

Simply add a matching CSS class in your site's global style sheet to change the link text appearance. You can add a CssClass to the control's <span /> element, or include in a <td /> to center the rendered control.

Please feedback any suggestions for improvements to this control.

Download the sample files: EAP_2002.zip (56Kb)


© 2001 - 2006 Triumph Media Limited. All rights reserved.
Microsoft Corporation is in no respect affiliated with www.mcmsfaq.com.
harbar.net