Code Samples
As some of you already noticed: GotDotNet is now down and the code samples previously hosted there have been migrated to the MSDN code gallery.
For your convenience here are links to all my code samples:
-
The HtmlPlaceholderControl shipped with CMS 2002 does not provide WYSIWYG. This means while editing the style added to the template are not applied to the content. The attached placeholder control will add this feature. It does only support styles added by external CSS files not styles added directly within style tags.
-
Template without an HtmlPlaceholder control included. The HtmlPlaceholder control will be added dynamically in the Page_Load event. Can be modified to allow dynamic number of placeholder controls per page.
-
This framwork allows easy development of MembershipProviders for MCMS. See
here for more details.
-
These are two samples to use SDAPI from managed Code. To build these two console applications you need to add a reference to the following server-side SDAPI dll. To do this select the following DLL from the list of COM based DLL's in the Reference Dialog: "MSCMS Site Deployment (Server-side)"
-
This sample implements an workaround for the fact that there is no API to create custom channel properties using PAPI.
-
This is a sample placeholder control which allows content validation. It is required that you also replace the standard ReeditSaveAction, SaveNewAction and ReeditSaveAndExitAction with the version included in this sample to ensure that the validation is fired on save.
-
This HttpModule makes it easy to SSL enable parts of a MCMS Web site. It manages switching between SSL and http for dedicated channels. No additional coding in the template project is required. Just integrated this http module and set the RequireSSL custom channel property to "yes". The rest will be handled by the http module.
-
This Console Extension can be used to replace the standard "Create New Page" Action. It will check the current channel for the DefaultTemplateGallery attribute and open the Template Gallery Explorer at the defined gallery if defined.
-
This console extension adds a new dialog to the decline action to ask for a reason when doing a decline action. The input is added to the data sent to the server and can be evaluated in the workflow event by reading Request.Form["DeclineReason"];
-
This is a "proof-of-concept" and not a ready to use solution to show how to implement a ConsoleAction to do updates on the server when Webauthor is in unpublished mode. It shows how to implement the redirect to update mode to ensure that the update can be done and the additional redirect to unpublished mode. I would recommend this sample to everyone who is interested in developing this kind of Console Extensions.
-
These Console Actions call ReleaseOwnership after each save to ensure that every Author is able to edit a Posting. Otherwise the Posting is locked until the Author submits his changes. This version also contains action for Save New and Save (without Exit)
-
The SingleImagePlaceholderControl and SingleAttachmentPlaceholderControl have a small bug: they render a link to an image named transparent.jpg in the current directory.
As this is only a cosmetic bug that causes 404 errors in the IIS log this bug will not be fixed in a hotfix. As this is still an anoying problem for some users I have implemented two custom placeholder controls derived from the original placeholder controls which fix the problem.
-
An often requested feature is to create a template definition programmatically (e.g. to replace the MCMS Template Explorer). This includes adding of placeholder definitions and custom property definitions to the template definition. This sample demonstrates how this can be achieved.
-
This is a placeholder control based on the Calendar Control which allows the author to pick a date and store it it in the placeholder object.
-
MCMS does not provide a mechanism to identify if a resource gallery item is currently being used by a posting or not. This DLL closes this gap by allowing to get a collection creating a report for all resource gallery items showing all postings pointing to a specific resource.
-
This PlaceholderControl allows the author to select a specified value from a DropDownList.
-
The CmsAuthorizationModule shipped with MCMS does not work properly when using a MCMS posting as login page. This module can be used as replacement for the out-of-the-box control and solves this problem.
-
Enhanced Version of RobotMetaTag Server control that also works in Channel Rendering Scripts. The version shipped with MCMS only works in Postings
-
This sample demonstrates how to export resource galleries using SDAPI. SDAPI does not allow to do this directly so a helper posting is generated that gets links to all resource gallery items. After the export is done the helper posting is deleted. To import it either use normal methods or extend your import script to remove the helper posting also on the production machine.
-
This sample placeholder control demonstrates how to extend the standard HtmlPlaceholderControl in authoring mode with new functionality. On button click it inserts a preformatted table to easily create FAQ pages.
-
Html Placeholder Control which is only visible in unpublished and authoring mode. Good for side notes and hints to authors or editors which should not show up on the live site
-
Using the hidden attribute of a HtmlPlaceholder control or hiding a placeholder control though other methods like inline code in the template file causes problems in authoring mode (e.g. loosing content in hidden controls). This placeholder control exposes its own property to hide and show and also preserves the content when hidden in authoring mode.
-
ASP.NET 2.0 introduces a new feature to allow cross-Postbacks to other webforms using the PostBackUrl property.
This method is very nice and allows to replace ugly workaround that were required in ASP.NET 1.x like using GET requests with query strings or adding client side script that cleared the viewstate form field.
There is only one caveat with this new method: It does not work with MCMS 2002. MCMS 2002 Service Pack 2 which is required to allow MCMS to work with ASP.NET 2.0 adds some additional client side javascript code that prevents the PostBackUrl property from working properly as it always changes the Url back to the MCMS template file. So the logic of this client side script does not handle the cross-Postback situation correct.
This http module allows to resolve the problem.
See
here for details.
-
When postbacks happen by switching from edit mode to live mode or being caused by ASP.NET controls the URL in a browser will become an ugly string. This HttpModule solves this. Details see
here.
Last updated based on the infos
here.
-
When postbacks happen by switching from edit mode to live mode or being caused by ASP.NET controls the URL in a browser will become an ugly string. This is the ASP.NET 2.0 version of the HttpModule that solves this. Details see
here.
-
ASP.NET 2.0 generates different html code as ASP.NET 1.1. The Javascript code from MCMS is not compatible with the new format. This http module adjusts the the html to work with MCMS 2002 SP1a.
See
here for more details.
-
Stylessheets for ASP.NET 2.0 themes are registered using a relative path. This HttpModule corrects this problem. More details
here.
-
Newer versions of IE do no longer autoactivate ActiveX controls. To overcome this limitation I have created this custom HtmlPlaceholderControl which does not suffer from this problem.
Details
here.
-
This placeholder control does the same as the standard image placeholder control but it allows alignment of the placeholder control based on a control property.
-
This placeholder control demonstrates how to utilize the Resource Gallery and Hyperlink Dialogs the placeholder controls shipped with CMS are using. It replaces the image in an onmouseover and onmouseout action. In authoring mode it allows the user to select both images and the hyperlink destination if required.
-
Sample provider which can be used with the ASP.NET 2.0 navigation controls to implement site navigation with MCMS.
Details see
here.
Updated version is
here.
-
This sample demonstrates how to utilize the methods to access the Resource Gallery as done by the placeholder controls shipped with MCMS. It implements a placeholder control which can hold multiple attachments similar to the SingleImagePlaceholderControl shipped with MCMS.
-
Placeholder Control to demonstrate how to integrated PDF Content in Cms Postings
-
Sample placeholder control that allows to store all kind of tags including Javascript code, Object tags, IFRAMES, ... in a MCMS placeholder.
-
This sample demonstrates how to utilize a TextBox control as client side editor. This can be interesting in environments where no ActiveX controls can be used.
-
Sometimes it is necessary to define a default value for a html placeholder control and giving this default value using the description property of the placeholder definition is not sufficient (e.g. because the content should come from a database). This sample demonstrates how to define a custom placeholder controls that defines a default value. You only have to add the logic to define where the default value needs to come from.
-
A common question I received from customers is that they would like to edit property values during authoring time similar to editing placeholder content. This server control provides the solution for this.
Here is an article with more details.
-
Display a random image from a resource gallery the author configured. Non-Image items in the resource gallery will be ignored.
-
This is a channel rendering script that demonstrates how to list the content of a channel using a Grid Control and a Repeater Control.
-
This is a server control that behaves like a Placeholder in presentation mode. But it renders a Placeholder on a different posting! This can be used an a summary page or for common text (like legal notes or copyright) which need to be included on many postings. Supported Placeholders: HtmlPlaceholder, ImagePlaceholder and AttachmentPlaceholder (including generated Icon) and the Office variants.
-
Console Extension to revert a posting to a previous version.
-
This is a custom placeholder control for MCMS which can be used to display information published in an RSS feed somewhere in the internet on a MCMS Web site. Has several parameters to configure the feed. Also contains a css file which should be embedded into the template to get it displayed nicely.
-
This sample adds additional buttons to align an image in an HtmlPlaceholderControl
-
An often requested feature is a console extension which allows to save a page without being prompted for a name (e.g. the name should be generated by a business rule).
-
This sample shows how to upload all files in a directory to a Resource Gallery by code. Much quicker as drag and drop to Site Manager.
-
This Script will list all expired postings in the CMS repository
-
This is a sample to implement a CheckBoxPlaceholderControl to store bool values in convenient form.
-
This Webform can be used to resize images in a MCMS resource gallery before they are sent to the client. This can be used as a dynamic thumbnail generator. This webform opens the resource image as file stream, resizes it and sends the new image back to the browser.
-
Sample Placeholder Control for Shockwave Flash Movies. It uses an Attachment Placeholder to hold the Link to the Shockwave Flash Movie. Width and Height can be defined at template level but might be overridden in the AttachmentText property. Format (x,y).
-
MCMS 2002 does not allow to create a static copy of a MCMS Web site with ASP.NET based templates. Creating static copies is often very useful – e.g. when you create a CHM file based on your web site content or if you would like to archive a snapshot of the website at a specific time for documentation. The recommended method to create a static copy of a MCMS web site is to use a 3rd party web crawling tool. The problem with such tools is that they usually fail to work when the links between the posting are not rendered as html link but (e.g.) created with client side XML/XSL or JavaScript. This tool does not have this limitation.
-
Stripping HtmlPlaceholder control. It will remove unwanted tags from a HtmlPlaceholder. You could adjust this to your needs. The current version removes the Office XML tags and all font formatting information to allow stylesheets to apply correctly.
-
MCMS does not provide a mechanism to identify if a resource gallery item is currently being used by a posting or not. This tool closes this gap by creating a report for all resource gallery items showing all postings pointing to a specific resource.
-
I've often received requests from customers whether the tree view or list view elements can be sorted by default. And whether the default for the number of items being displayed can be changed as the default number of five items is not very comfortable. This solution addresses this. Additional information in the included Word document. Update: March. 02, 2005 - added sorting for postings in hyperlink dialog. I missed this in previous release.
-
WssAnalyzeFeaturesThis tool allows to verify if the feature definition files for all installed features are present on the file system. Also allows to verify if the features used in site collections an sites are installed on the server. In addition it can create a checklist file which can be used to verify if a server has all features installed required to act as destination for a content deployment job of an existing sitecollection.
-
WssRemoveFeatureFromSiteIn some situation the STSADM command STSADM.EXE -o deactivatefeature is not able to deactivate a feature either on site collection or on site level.
This can (e.g.) happen if the feature definition for the feature that has to be removed is not installed in the farm.
This tool allows to remove the feature from the site or site collection completly.