Travails of an ungeeker

Friday, May 12, 2006

ASP.NET validator controls throw an Exception in MCMS by default

If you add an ASP.NET validator to an MCMS template you get a strange error like: MCMS Object has been deleted. An attempt was made to access the properties or methods of an object that was deleted by the current session.

First you'll find that a service pack for MCMS 2002 SP1a exists but which Microsoft discourages you from installing. Taking their advise and looking further you will find that the problem lies with the Web Author Console, where the standard processing of validator controls is not enabled by the default. Perhaps the service pack fixes that, but here is another way:

You can buy Stefan's book or just look at a posting from him here which shows the required code to add to make ASP.NET custom validation controls work.

http://www.gotdotnet.com/Community/UserSamples/Download.aspx
?SampleGuid=65F90778-465D-4A98-804F-2CCA72FF4704


There you will see you that you need to add some code to the AuthoringSaveNewAction method called by the Author Console. In your derived method, inject a call to Page_ClientValidate() which enables the validation support. That's for a new page save, so similar is requierd for AuthoringReeditSaveAction() and AuthoringReeditSaveAndExitAction().



Overriding the AuthoringSaveNewAction() of the console you need to inject a call to
if (this.Page.Validators.Count > 0) {
strReturn += "if (!Page_ClientValidate()) return false; ";
}

0 Comments:

Post a Comment

<< Home