1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / SoamProtector and postback

SoamProtector and postback

5 posts, 0 answered
  1. Marko
    Marko avatar
    148 posts
    Registered:
    30 Jul 2008
    14 Oct 2008
    Link to this post
    I have a form that, when submitted, it simply pulls up the same page again. Only, on successful submit, the original form controls are hidden, and the confirmation message is displayed.

    Now that I've added a Spam Protector  on the form, how can hide it on successful submit?  i tried this:

    Dim mySpamProtector As SpamProtector = Page.FindControl("SpamProtector1"
     
    If Page.IsValid Then 
        mySpamProtector.Visible = False 
    Else 
        mySpamProtector.Visible = True 
    End If 


    ...but it comes up with "object reference not set to an instance of an object". On my sitemap page, when I placed the SpamProtector control, I went into the advanced properties and made sure the ID is set to SpamProtector1.

    How do I do this?


  2. Marko
    Marko avatar
    148 posts
    Registered:
    30 Jul 2008
    14 Oct 2008
    Link to this post
    ...by the way, that was a typo in the thread subject...   soam = spam . sorry :-)
  3. Marko
    Marko avatar
    148 posts
    Registered:
    30 Jul 2008
    16 Oct 2008
    Link to this post
    Any help with this one?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    17 Oct 2008
    Link to this post
    Hi Marko,
     
    I tried the following:

    I created a Textbox control and add a label. Then add the spamprotector control and a submit button that validate the form. In the code behind I set similar functionality as you and when the form was validated I hid the spamprotector control, Textbox control and the button.

    Here is my code.

    <asp:TextBox ID="TextBox1" runat="server" ValidationGroup="test" /> 
    <asp:Label ID="label1" text="Label" runat="server" /> 
     
     
    <sfweb:spamprotector id="SpamProtector1" runat="server" 
                cssclass="commentsValidator hide" 
                validationgroup="test" 
                enableautobotdiscovery="true" 
                enablehiddentextboxstrategy="true" 
                hiddentextboxerrormessage="Hidden TextBox has some text in it!" 
                hiddentextboxlabel="Do not fill this textbox!" 
                hiddentextboxlabelcssclass="hide"  
                hiddentextboxinputcssclass="hide"  
                enablemintimeoutstrategy="true" 
                mintimeout="2" 
                mintimeouterrormessage="Submission too fast!" 
                EnableCaptcha="true"  
                CaptchaLength="2"/> 
                 
            <asp:Button ID="submitBtn" runat="server" Text="submit" 
                ValidationGroup="test" CssClass="sf_commentsSubmit"  
        onclick="submitBtn_Click" /> 
     

    .cs

         Protected Sub submitBtn_Click(sender As Object, e As EventArgs) 
            If Page.IsValid Then 
                 SpamProtector1.Visible = False 
                 submitBtn.Visible = False 
                 TextBox1.Visible = False 
                 label1.Text = "your request has been submitted!" 
             Else 
                 SpamProtector1.Visible = True 
                 submitBtn.Visible = True 
                 TextBox1.Visible = True 
             End If 
         End Sub 


    I hope this helps.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  5. Marko
    Marko avatar
    148 posts
    Registered:
    30 Jul 2008
    17 Oct 2008
    Link to this post
    Excellent, it works great!

    What I did wrong was: I added the SpamProtector control by dragging and dropping it in Sitemap edit mode (on a particular page).  I thought I could reference it that way, too, but I was wrong.  This works much better.

    Thanks!

    p.s.  FYI to anyone else wanting to do this, don't forget to register the assembly in your ASCX file (it took me a few minutes to realize that I needed this too):

    <%@ Register Assembly="Telerik.Cms.Web.UI" Namespace="Telerik.Web.UI.SpamProtection" TagPrefix="sfWeb" %> 

Register for webinar
5 posts, 0 answered