in

dotNetFreak

Ramblings & Controls from a .NET Addicted Freak!

Kevin Gearing's Blog

Adding FormShield to Community Server 2007 - Blog Comments

Adding FormShield to the blog comments area of Community Server 2007 is fairly straightforward.

Brief instructions are below, I've also uploaded a copy of the 'post.aspx' and 'web.config' files showing these changes to here.


1. Download the 'web.config' file for the site and add the following before <connectionStrings ... />:

<appSettings>
<add key="formShield_SecretKey" value="!--FormShield--!" />

</appSettings>


2. Also in the 'web.config' file, add the following in the <httpHandlers ... /> area:

<add verb="GET" path="FormShield.aspx" type="dotNetFreak.WebControls.FormShieldHttpHandler, dotNetFreak.WebControls.FormShield" />


3. Copy the 'dotNetFreak.WebControls.FormShield.dll' and 'dotNetFreak.WebControls.FormShield.BritishMale8kHz8bitMonoWavSoundLibrary.dll' files to the 'bin' directory.


4. Download the 'post.aspx' file for the theme you are using - e.g. '/Themes/Blogs/default/post.aspx'.


5. At the top of the file underneath '<% Page Language="C#" ... /> add:

<%@ Register Assembly="dotNetFreak.WebControls.FormShield" Namespace="dotNetFreak.WebControls" TagPrefix="dnf" %>


6. Scroll down in the file until you see:

<div class="CommonFormField" id="Remember" runat="server">

<asp:CheckBox id="chkRemember" runat="server" Text="Remember Me?" />

</div>


Then add the following directly beneath it:

<div>

<br />

<dnf:FormShield ID="FormShield1" runat="server" HttpHandlerPath="/FormShield.aspx" PersistenceMethod="ControlState">

<RefreshIcon AlternateText="Refresh" />

<SoundIcon AlternateText="Listen" />

<HelpIcon AlternateText="Please enter the characters shown on the image" />

</dnf:FormShield>

<br /><br />

Code: <asp:TextBox ID="TextBox1" width="208px" runat="server" />

<br /><br />

<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="Please enter the code." Display="Dynamic" ValidationGroup="CreateCommentForm" />

<asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="FormShield1" ControlToValidate="TextBox1" EnableClientScript="False" ErrorMessage="Invalid code entered." Display="Dynamic" ValidationGroup="CreateCommentForm" />

<br />

</div>


7. Save and upload the files and you are done!

Comments

 

Dave Burke said:

blog bits Julian Bucknall blogs on one of my favorite Community Server topics, his experience with the

July 14, 2007 5:56 PM
 

Community Blogs said:

blog bits Julian Bucknall blogs on one of my favorite Community Server topics, his experience with the

July 14, 2007 6:18 PM
 

Dave Burke's Community Server Bits said:

Kevin Gearing releases a sophisticated Captcha control which includes sound support called FormShield

July 14, 2007 8:54 PM
 

Jeff Bishop said:

I added the control to the paperclip theme and modified the post.aspx of that theme and it doesn't work.  Also, if I log in that code doesn't appear as well (meaning the textbox to enter the code).  I would also like to insure all characters are lowercase as well as numbers (no mixed case) so any help in that area would be great.  Clicking the listen link plays nothing and clicking submit does nothing either.  Here is the file I modified (post.aspx):

<%@ Page Language="C#" AutoEventWireup="true" EnableViewState="False" MasterPageFile="theme.Master" Inherits="CommunityServer.Blogs.Controls.CSBlogThemePage" %>

<%@ Register Assembly="dotNetFreak.WebControls.FormShield" Namespace="dotNetFreak.WebControls" TagPrefix="dnf" %>

<%@ Import namespace="CommunityServer.Components"%>

<%@ Import namespace="CommunityServer.Blogs.Components"%>

<script runat="Server">

   void Page_Load(object sender, EventArgs e)

   {

       if (CurrentWeblogPost != null)

           SetTitle(CurrentWeblogPost.Subject, false);

   }

</script>

<asp:Content ID="Content1" ContentPlaceHolderID="Main" runat="Server">

   <div class="post">

      <CSBlog:WeblogPostData runat="server" Property="Subject" Tag="H2" CssClass="pageTitle" />

      <CSBlog:WeblogPostData Property="FormattedBody" IncrementViewCount="true" runat="server" />

      <CSBlog:WeblogPostData ResourceName="Weblog_ReadMirroredPost" Property="TitleUrl" runat="server">

       <DisplayConditions><CSBlog:WeblogPostPropertyValueComparison runat="server" ComparisonProperty="IsExternal" Operator="IsSetOrTrue" /></DisplayConditions>

       <LeaderTemplate><p><i></LeaderTemplate>

       <TrailerTemplate></i></p></TrailerTemplate>

   </CSBlog:WeblogPostData>

       <div class="postfoot">

           <CSBlog:PostAttachmentData runat="server" LinkTo="Attachment" Tag="Div" Property="FileName"><LeaderTemplate><span class="em">Attachment:</span> </LeaderTemplate></CSBlog:PostAttachmentData>

           <span class="em">Posted:</span>

           <CSBlog:WeblogPostData Property="UserTime" LinkTo="Post" FormatString="MMM dd yyyy, hh:mm tt" runat="server" />

<CSControl:ResourceControl runat="server" ResourceName="Weblog_EntryList_By" id="PostByResource" />

<CSBlog:WeblogPostData Property="DisplayName" LinkTo="AuthorUrl" runat="server" />

<CSControl:PlaceHolder runat="server">

<DisplayConditions Operator="Not"><CSBlog:WeblogPostPropertyValueComparison runat="server" ComparisonProperty="IsExternal" Operator="IsSetOrTrue" /></DisplayConditions>

               <ContentTemplate>

                   <CSBlog:WeblogPostData Text="{0} comment(s)" Property="Replies" LinkTo="PostComments" runat="server">

                       <LeaderTemplate>| <CSControl:ResourceControl runat="server" ResourceName="Weblog_EntryList_With" id="CommentDesc"/> </LeaderTemplate>

                       <DisplayConditions><CSBlog:WeblogPostPropertyValueComparison runat="server" ComparisonProperty="Replies" ComparisonValue="0" Operator="GreaterThan" /></DisplayConditions>

                   </CSBlog:WeblogPostData>

                   <CSBlog:WeblogPostData Text="no comments" Property="Replies" LinkTo="PostComments" runat="server">

                       <LeaderTemplate>| <CSControl:ResourceControl runat="server" ResourceName="Weblog_EntryList_With" id="CommentDesc"/> </LeaderTemplate>

                       <DisplayConditions><CSBlog:WeblogPostPropertyValueComparison runat="server" ComparisonProperty="Replies" ComparisonValue="0" Operator="LessThanOrEqualTo" /></DisplayConditions>

                   </CSBlog:WeblogPostData>

               </ContentTemplate>

           </CSControl:PlaceHolder>

           <CSBlog:WeblogPostRating runat="server" RatingCssClass="RateControl" RatingReadOnlyCssClass="RateControlReadOnly" RatingActiveCssClass="RateControlActive" ImagesBaseUrl="~/Themes/default/images/common/">

               <LeaderTemplate>| </LeaderTemplate>

           </CSBlog:WeblogPostRating>

           <CSBlog:WeblogPostData LinkTo="PostEditor" ResourceName="Weblog_Link_EditPost" runat="server"><LeaderTemplate>| </LeaderTemplate></CSBlog:WeblogPostData>

           <CSBlog:WeblogPostTagEditableList runat="server" EditorLinkCssClass="TextButton" EditorCssClass="InlineTagEditor" Tag="Div" CssClass="em" />

       </div>    

   </div>

   <CSControl:PlaceHolder runat="server">

<DisplayConditions Operator="Not"><CSBlog:WeblogPostPropertyValueComparison runat="server" ComparisonProperty="IsExternal" Operator="IsSetOrTrue" /></DisplayConditions>

       <ContentTemplate>

           <CSBlog:WeblogFeedbackList runat="server">

               <QueryOverrides PageSize="999999" />

               <LeaderTemplate>

                   <div id="comments">

                   <a name="Comments" />

                   <CSControl:ResourceControl runat="server" ResourceName="Weblog_CommentForm_Comments" Tag="H2" />

               </LeaderTemplate>

               <ItemTemplate>

                   <div class="<%# ((bool) Eval("IsOwner")) ? "CommentAreaOwner" : "CommentArea" %>">

           <h4 class="CommentTitle">

           <CSBlog:WeblogPostFeedbackData runat="server" LinkTo="User" Property="DisplayName" />

           <CSControl:resourcecontrol runat="server" resourcename="Weblog_CommentForm_Said" ID="Resourcecontrol1" />

           <CSBlog:ThemeImage runat="server" ImageUrl="~/images/spacer.gif" ImageAlign="bottom" CssClass="CommentArrow" AlternateText=" " />

           </h4>

           <div class="CommentText">

           <div class="CommentText2">

           <div class="CommentText3"><CSBlog:WeblogPostFeedbackData runat="server" Property="FormattedBody" /></div>

           </div>

           </div>

           <div class="CommentFooter">

               <CSBlog:WeblogPostFeedbackData runat="server" LinkTo="Feedback" Text="#" />

               <CSBlog:WeblogPostFeedbackData runat="server" Property="PostDate" FormatString="MMMM d, yyyy h:mm tt" />

                           <CSBlog:DeleteWeblogPostFeedbackForm DeleteButtonId="DeleteComment" ConfirmationResourceName="Weblog_Comment_DeleteVerify" runat="server">

                               <SuccessActions>

                               <CSControl:GoToModifiedUrlAction runat="server" />

                           </SuccessActions>

                               <FormTemplate>

                                   [<asp:LinkButton runat="server" Text="Delete" ID="DeleteComment" />]

                               </FormTemplate>

                           </CSBlog:DeleteWeblogPostFeedbackForm>

                       </div>

           </div>

               </ItemTemplate>    

               <NoneTemplate>

                   <p><CSControl:ResourceControl runat="server" resourcename="Weblog_CommentForm_NoComments" /></p>

               </NoneTemplate>

               <TrailerTemplate>

                   </div>

               </TrailerTemplate>

           </CSBlog:WeblogFeedbackList>

           <CSControl:ResourceControl runat="server" ResourceName="Blog_Pending_Comment" Tag="Strong">

               <DisplayConditions>

                   <CSControl:QueryStringPropertyValueComparison QueryStringProperty="CommentPosted" Operator="IsSetOrTrue" runat="server" />

               </DisplayConditions>

               <LeaderTemplate><a name="commentmessage"></a></LeaderTemplate>

           </CSControl:ResourceControl>

           <CSBlog:WeblogPostCommentForm runat="server" ValidationGroup="CreateCommentForm"

               MessageTextBoxId="tbComment"

               NameTextBoxId="tbName"

               RememberCheckboxId="chkRemember"

               SubjectTextBoxId="tbTitle"

               SubmitButtonId="btnSubmit"

               UrlTextBoxId="tbUrl"

               ControlIdsToHideFromRegisteredUsers="RememberWrapper"

           >

               <SuccessActions>

                   <CSControl:GoToModifiedUrlAction runat="server" QueryStringModification="CommentPosted=true" TargetLocationModification="commentmessage" />

               </SuccessActions>

               <FormTemplate>

                   <fieldset id="commentform">

                   <legend><CSControl:ResourceControl runat="server" ResourceName="Weblog_CommentForm_WhatDoYouThink" id="rc_think"/></legend>

                   <p />

                       <div><CSControl:FormLabel runat="server" ResourceName="Title" LabelForId="tbTitle" /> <em>(<CSControl:ResourceControl runat="server" ResourceName="Required"/>)</em><asp:RequiredFieldValidator runat="server" ErrorMessage="*" ControlToValidate="tbTitle" ValidationGroup="CreateCommentForm" /></div>

                   <div><asp:TextBox id="tbTitle" runat="server" CssClass="smallbox" ValidationGroup="CreateCommentForm" /></div>

                   <p />

                       <div id="NameTitle" runat="server"><CSControl:FormLabel LabelForId="tbName" runat="server" ResourceName="Weblog_CommentForm_Name" /> <em>(<CSControl:ResourceControl runat="server" ResourceName="Required" />)</em><asp:RequiredFieldValidator runat="server" ErrorMessage="*" ControlToValidate="tbName" ValidationGroup="CreateCommentForm" /></div>

                       <div id="NameDesc" runat="server"><asp:TextBox id="tbName" runat="server" CssClass="smallbox" ValidationGroup="CreateCommentForm" /></div>

                       <p />

                       <div><CSControl:FormLabel runat="server" LabelForId="tbUrl" ResourceName="Weblog_CommentForm_YourUrl" /> <em>(<CSControl:ResourceControl runat="server" ResourceName="Optional" /></em>)</div>

                       <div><asp:TextBox id="tbUrl" runat="server" CssClass="smallbox" ValidationGroup="CreateCommentForm" /></div>

                       <p />

                       <div><CSControl:FormLabel LabelForId="tbComment" runat="server" ResourceName="Weblog_CommentForm_Comments" /> <em>(<CSControl:ResourceControl runat="server" ResourceName="Required" />)</em><asp:RequiredFieldValidator runat="server" ErrorMessage="*" ControlToValidate="tbComment" ValidationGroup="CreateCommentForm" /></div>

                       <div><asp:TextBox id="tbComment" runat="server" Rows="5" Columns="25" TextMode="MultiLine" ValidationGroup="CreateCommentForm" /></div>

                   <asp:PlaceHolder runat="server" id="RememberWrapper">

                       <p />

<div><asp:CheckBox id="chkRemember" runat="server" Text="Remember Me?" ValidationGroup="CreateCommentForm"></asp:CheckBox></div>

                        <div>

                            <br />

                            <dnf:FormShield ID="FormShield1" runat="server" HttpHandlerPath="/FormShield.aspx" PersistenceMethod="ControlState">

                                <RefreshIcon AlternateText="Refresh" />

                                <SoundIcon AlternateText="Listen" />

                                <HelpIcon AlternateText="Please enter the characters shown on the image" />

                            </dnf:FormShield>

                            <br /><br />

                            Code: <asp:TextBox ID="TextBox1" width="208px" runat="server" />

                            <br /><br />

                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="Please enter the code." Display="Dynamic" ValidationGroup="CreateCommentForm" />

                            <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="FormShield1" ControlToValidate="TextBox1" EnableClientScript="False" ErrorMessage="Invalid code entered." Display="Dynamic" ValidationGroup="CreateCommentForm" />

                            <br />

                        </div>

                       </asp:PlaceHolder>

                   <p />

                       <asp:Button id="btnSubmit" runat="server" Text="Submit" ValidationGroup="CreateCommentForm"></asp:Button>

                   </fieldset>

               </FormTemplate>

           </CSBlog:WeblogPostCommentForm>

       </ContentTemplate>

   </CSControl:PlaceHolder>

</asp:Content>

Anyone got any ideas?  The instructions were not exact for this theme it seems.

July 16, 2007 12:03 AM
 

Jeff Bishop said:

OK, everything seems to work (although I am blind so I can not see the images) but the audio will not play when the listen link is clicked.  Any ideas?

July 16, 2007 12:26 AM
 

Jeff Bishop said:

OK, here is the error for the non-playing audio for the CAPTCHA control:

UnknownError

66.93.152.109

07-15-2007, 05:39 PM

5

User Agent: Windows-Media-Player/9.00.00.3349

Path: /FormShield.aspx?__formShieldID=FormShield1&generate=sound&properties=0A791B6E6835B79CF4CD135F5916F060 as HTTP GET

Referrer:

Message: Object reference not set to an instance of an object.

System.NullReferenceException: Object reference not set to an instance of an object.

at 6P9R5oYd9mHdresZdg2.VirN13Yp8llhgXdpRJN.6ZgYPSJbYr(String , String )

at 6P9R5oYd9mHdresZdg2.VirN13Yp8llhgXdpRJN.tnAYLjYEOJ()

at dotNetFreak.WebControls.FormShieldHttpHandler.ProcessRequest(HttpContext context)

at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()

at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

 

Any ideas?

July 16, 2007 12:46 AM
 

Kevin Gearing said:

Hi Jeff,

Great that you've got the control working with the paperclick theme!

If you want to make it so that FormShield only generates lowercase characters and also numbers, add TextCase="Lower" after HttpHandlerPath="/FormShield.aspx". By default FormShield uses alphanumeric characters, so you don't need to add any extra setting for that.

I've just checked your Web site and can see that the images are displayed, but like you mention the sound isn't working. Have you uploaded any SoundLibrary assembly?

If you look in the 'demo\bin' directory of the download you will find dotNetFreak.WebControls.FormShield.BritishMale8kHz8bitMonoWavSoundLibrary.dll - this must be uploaded into your bin directory along with the control.

If you would prefer to use a female voice, you can download one from the downloads area above.

Let me know if you are still having problems.

July 16, 2007 11:19 AM
 

Jeff Bishop said:

Yes, I uploaded the sound libraries, I posted the error found in the exceptions report to this blog.

July 16, 2007 2:36 PM
 

Kevin Gearing said:

Jeff: I've sent you an e-mail.

July 16, 2007 5:52 PM
 

Sonu Kapoor [MVP] said:

Thanks for the post.

November 13, 2007 3:05 PM
 

Erotik Hikayeler said:

Thanks for post...

November 30, 2008 1:13 AM

Leave a Comment

(required)  
(optional)
(required)  

Protected by FormShield
Refresh
Listen
Please enter the characters shown on the image


Code:


Add
Copyright ©2004-2007 Kevin Gearing. All Rights Reserved.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems