|
Home > Archive > Microsoft Content Management Server > January 2005 > Cms2002 not cancelling save event
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Cms2002 not cancelling save event
|
|
| wheels 2005-01-31, 5:53 pm |
| 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["StartDate"]).Text);
}
catch
{
ValidDate = false;
}
if (!ValidDate)
{
e.Cancel = true;
}
}
| |
| Stefan [MSFT] 2005-01-31, 5: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;
>
> }
>
>
>
> }
>
>
|
|
|
|
|