CMS Placeholder Validation
Windows Server Forum Index Windows Server
Server discussion on Windows platform.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web winserverhelp.com
CMS Placeholder Validation

 
Post new topic   Reply to topic    Windows Server Forum Index -> CMS Server
Author Message
Kele
Guest





Posted: Tue Jan 04, 2005 11:52 am    Post subject: CMS Placeholder Validation Reply with quote

Is there any good way of being able to implement
Validation on a CMS Placeholder in the Template. eg.
Date Validation ie for Release Date Placeholder.

Are you able to use the validation controls against a
placeholder? If so how do you do this?

Thanks,
Kele.
Back to top
fs
Guest





Posted: Tue Jan 04, 2005 12:49 pm    Post subject: RE: CMS Placeholder Validation Reply with quote

Hi Kele,

There are more than one way to do this, but depending on how complex your
validations are and how many fields you want to validate.

In my case, I once did a template with five fields that has date range
validations, and regular expression matchings. My approach is to create these
fields using normal asp.net controls and throw in a couple of asp.net
validation controls for each of them. These validations will fire
automatically on client-side lost focus and postback.
Then I also have a hidden placeholder, which I populate with an xml string
of the validated values of each field on postback. The validations work just
like a normal asp.net page, but we have to bind the validated xml string from
the hidden placeholder to whatever presentation we want in presentation mode.
This might be a step too many for a single field validation, thus
alternatively we can just write our validation codes in the onsubmitting
event handler. It looks something like this:

public void CmsPosting_Submitting(Object sender, ChangingEventArgs e)
{
Posting currentPosting = (Posting) e.Target;
HTMLPlaceholder validatePlaceholder;
validatePlaceholder = (HTMLPlaceholder)
currentPosting.Placeholders["myPlaceholder"];
if (validatePlaceholder != null) //this will skip validation codes for
other postings
{
bool isValid = false;
//validation code goes here
//example:
//try {
// if (int.Parse(validatePlaceholder.Text)) > 10) isValid = true;
// catch
// {}

if (!isValid) //validation failed
{
Exception customException = new Exception("Value must be integer
greater than 10!");

//get webauthor context and raise the error
WebAuthorContext webAuthCtx = WebAuthorContext.Current;
webAuthCtx.RaiseErrorEvent(new
WebAuthorErrorEventArgs("FailedSubmit", customException);

//cancels the submit
e.Cancel = true;
e.SuppressExceptionOnCancel = true;
}
}
}

Hope this helps...


"Kele" wrote:

Quote:

Is there any good way of being able to implement
Validation on a CMS Placeholder in the Template. eg.
Date Validation ie for Release Date Placeholder.

Are you able to use the validation controls against a
placeholder? If so how do you do this?

Thanks,
Kele.

Back to top
Stefan [MSFT]
Guest





Posted: Tue Jan 04, 2005 3:06 pm    Post subject: Re: CMS Placeholder Validation Reply with quote

Hi Kele,

please check this ready to use solution:
http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=65F90778-465D-4A98-804F-2CCA72FF4704

Cheers,
Stefan.


"Kele" <anonymous@discussions.microsoft.com> wrote in message
news:0c0101c4f221$8e96da30$a501280a@phx.gbl...
Quote:

Is there any good way of being able to implement
Validation on a CMS Placeholder in the Template. eg.
Date Validation ie for Release Date Placeholder.

Are you able to use the validation controls against a
placeholder? If so how do you do this?

Thanks,
Kele.
Back to top
 
Post new topic   Reply to topic    Windows Server Forum Index -> CMS Server All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




New Topics Powered by phpBB