Cms2002 not cancelling save event
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Microsoft Content Management Server > Cms2002 not cancelling save event




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Cms2002 not cancelling save event  
wheels


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-31-05 10: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;

}



}







[ Post a follow-up to this message ]



    Re: Cms2002 not cancelling save event  
Stefan [MSFT]


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
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 ]



    Sponsored Links  




 





   All times are GMT. The time now is 11:05 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register