01-31-05 10:53 PM
Hi,
this is not a valid way to prevent saving of a posting.
It will only prevent saving of the current placeholder. All other
placeholders earlier in the event change already have been saved at this
time.
To validate content you should implement a validator similar to this one:
http://www.gotdotnet.com/Community/...4F-2CCA72FF4704
Cheers,
Stefan
"wheels" <wheels@discussions.microsoft.com> wrote in message
news:0CD9794F-01D5-4640-80DA-7005804BCC3C@microsoft.com...
> I have just written the following code to prevent an author saving a
posting
> without a valid start date. However in the following code, in which
cancel
> is definitely set to true with a blank date (I have traced this and
e.Cancel
> is definitely being executed), pages are still saved.
>
> any ideas
>
>
> private void DatePickerPlaceholder1_SavingContent(obj
ect
sender,
> PlaceholderControlSavingEventArgs e)
>
> {
>
> bool ValidDate = true;
>
> DateTime TestDate;
>
> Posting CurrentPosting = CmsHttpContext.Current.Posting;
>
>
>
> try
>
> {
>
> TestDate =
>
System.Convert. ToDateTime(((HtmlPlaceholder)CurrentPost
ing.Placeholders[
"Sta
rtDate"]).Text);
>
> }
>
> catch
>
> {
>
> ValidDate = false;
>
> }
>
>
>
> if (!ValidDate)
>
> {
>
> e.Cancel = true;
>
> }
>
>
>
> }
>
>
[ Post a follow-up to this message ]
|