Microsoft Content Management Server - Custom Placeholder / Saving / reverting issues

This is Interesting: Free IT Magazines  
Home > Archive > Microsoft Content Management Server > August 2004 > Custom Placeholder / Saving / reverting issues





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 Custom Placeholder / Saving / reverting issues
Chris

2004-08-24, 7:00 pm

Stefan, thanks for your reply yesterday... I tooka different approach
and was wondering if someone could help me with this....

I created a customer placeholder control with two properties (maxlength
(int) and required (bool)). Basically, when the author tries to save
the posting, the placeholder control will check itself to see if the
text is within the constraints... if not, i display an error.. when you
raise an ErrorModeContainer.FailedSavePlaceholder it reverts the text
the user typed back to the last 'valid' version.. I'd rather have what
they typed in the control still be display for them to go back and edit
to the correct length.. here is my custom class save method...

Protected Overrides Sub SavePlaceholderContent(ByVal e As
Microsoft.ContentManagement.WebControls.PlaceholderControlSaveEventArgs)

MyBase.SavePlaceholderContent(e)

Dim errmsg As String = ""
Dim ThisPH As
Microsoft.ContentManagement.Publishing.Extensions.Placeholders.HtmlPlaceholder
= MyBase.BoundPlaceholder

If maxlength <> -1 Then
If ThisPH.Datasource.RawContent.Replace("&nbsp;", "").Length >
maxlength Then
errmsg = friendlyname & " exceeds maxlength (" & maxlength.ToString
& ")."
End If
End If

If _Required Then
If ThisPH.Datasource.RawContent.Replace("&nbsp;", "").Length = 0
Then
errmsg = "Content is required for " & friendlyname
End If
End If

If errmsg.Length > 0 Then
Dim err As New
Microsoft.ContentManagement.WebControls. WebAuthorErrorEventArgs(ErrorModeContain
er.FailedSavePlaceholder,
New Exception(errmsg))
Microsoft.ContentManagement.WebControls.WebAuthorContext.Current.RaiseErrorEvent(err)
' right here is where i'd like to set the
rawcontent back to what the user typed in if possible?
End If


End Sub

Stefan [MSFT]

2004-08-24, 7:00 pm

Hi Chris,

see here about usage of RawContent:
http://blogs.msdn.com/stefan_gossne.../24/119546.aspx

Cheers,
Stefan.

--
This posting is provided "AS IS" with no warranties, and confers no rights.

MCMS FAQ:
http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm
MCMS Blog: http://blogs.msdn.com/stefan_gossner/category/4983.aspx
MCMS Sample Code:
http://www.gotdotnet.com/community/...t+S
erver

MCMS Whitepapers and other docs:
http://blogs.msdn.com/stefan_gossne...2/07/41859.aspx
--------------------------------


"Chris" <cbarr42k@yahoo.com> wrote in message
news:cgg1gl$5q2@odbk17.prod.google.com...
> Stefan, thanks for your reply yesterday... I tooka different approach
> and was wondering if someone could help me with this....
>
> I created a customer placeholder control with two properties (maxlength
> (int) and required (bool)). Basically, when the author tries to save
> the posting, the placeholder control will check itself to see if the
> text is within the constraints... if not, i display an error.. when you
> raise an ErrorModeContainer.FailedSavePlaceholder it reverts the text
> the user typed back to the last 'valid' version.. I'd rather have what
> they typed in the control still be display for them to go back and edit
> to the correct length.. here is my custom class save method...
>
> Protected Overrides Sub SavePlaceholderContent(ByVal e As
> Microsoft.ContentManagement.WebControls.PlaceholderControlSaveEventArgs)
>
> MyBase.SavePlaceholderContent(e)
>
> Dim errmsg As String = ""
> Dim ThisPH As
>

Microsoft.ContentManagement.Publishing.Extensions.Placeholders.HtmlPlacehold
er
> = MyBase.BoundPlaceholder
>
> If maxlength <> -1 Then
> If ThisPH.Datasource.RawContent.Replace("&nbsp;", "").Length >
> maxlength Then
> errmsg = friendlyname & " exceeds maxlength (" & maxlength.ToString
> & ")."
> End If
> End If
>
> If _Required Then
> If ThisPH.Datasource.RawContent.Replace("&nbsp;", "").Length = 0
> Then
> errmsg = "Content is required for " & friendlyname
> End If
> End If
>
> If errmsg.Length > 0 Then
> Dim err As New
>

Microsoft.ContentManagement.WebControls.WebAuthorErrorEventArgs(ErrorModeCon
tainer.FailedSavePlaceholder,
> New Exception(errmsg))
>

Microsoft.ContentManagement.WebControls.WebAuthorContext.Current.RaiseErrorE
vent(err)
> ' right here is where i'd like to set the
> rawcontent back to what the user typed in if possible?
> End If
>
>
> End Sub
>



Chris

2004-08-24, 7:00 pm

Hm.. OK I read this and it makes sense so I changed my code... But, for
my main question, how would I go about setting the HTML/TEXT property
back to what it was the user typed in instead of reverting back to the
last saved version? IE.

Text original state before edit: Test String
Text after edit: Test String to break

After clicking save... the webauthorcontext is going to raiseerrorevent
because the length of the typed in string is greated than I am allowing
in my custom property.. So at this point, how would I keep the
placeholder text to be what the user just typed in, instead of it
reverting back to the original "Test String"

Stefan [MSFT]

2004-08-24, 7:00 pm

Hi Chris,

this content needs to be in a Request.Form variable.
Pick it up there.

Cheers,
Stefan.

--
This posting is provided "AS IS" with no warranties, and confers no rights.

MCMS FAQ:
http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm
MCMS Blog: http://blogs.msdn.com/stefan_gossner/category/4983.aspx
MCMS Sample Code:
http://www.gotdotnet.com/community/...t+S
erver

MCMS Whitepapers and other docs:
http://blogs.msdn.com/stefan_gossne...2/07/41859.aspx
--------------------------------


"Chris" <cbarr42k@yahoo.com> wrote in message
news:cgg3bn$rr4@odah37.prod.google.com...
> Hm.. OK I read this and it makes sense so I changed my code... But, for
> my main question, how would I go about setting the HTML/TEXT property
> back to what it was the user typed in instead of reverting back to the
> last saved version? IE.
>
> Text original state before edit: Test String
> Text after edit: Test String to break
>
> After clicking save... the webauthorcontext is going to raiseerrorevent
> because the length of the typed in string is greated than I am allowing
> in my custom property.. So at this point, how would I keep the
> placeholder text to be what the user just typed in, instead of it
> reverting back to the original "Test String"
>



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com