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

Forums / Developing with Sitefinity / how to override subscribe widget functionality?

how to override subscribe widget functionality?

3 posts, 0 answered
  1. rupali
    rupali avatar
    14 posts
    Registered:
    08 Mar 2016
    09 Mar
    Link to this post

    I am using  Sitefinity 7.1.5213.0 version.I have added radcaptcha in subscribe widget of sitefinity.captcha works fine but even after captcha not valid ,the user get subscribed .And user gets added into mailing list .But i dont want to add email into mailing list when captcha not valid.I have added captcha validation on subscribe button click event. Below is my code.

    Plz help me in it.

    ascx markup:

     

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="SubscribeFormCustomTemplate.ascx.cs" Inherits="SitefinityWebApp.UserControls.SubscribeFormCustomTemplate" %>
    <%--<%@ Control Language="C#" %>--%>
    <%@ Register TagPrefix="sitefinity" Namespace="Telerik.Sitefinity.Web.UI" Assembly="Telerik.Sitefinity" %>
    <%@ Register TagPrefix="telerik" Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" %>

    <%-- <script src="https://www.google.com/recaptcha/api.js" async defer></script>--%>
     
    <asp:Panel ID="errorsPanel" runat="server" CssClass="sfErrorSummary" Visible="false" />
    <fieldset id="formFieldset" runat="server" class="sfnewsletterForm sfSubscribe">
        <sitefinity:SitefinityLabel ID="widgetTitle" runat="server" WrapperTagName="h2" HideIfNoText="true" CssClass="sfnewsletterTitle" />
        <sitefinity:SitefinityLabel ID="widgetDescription" runat="server" WrapperTagName="p" HideIfNoText="true" CssClass="sfnewsletterDescription" />
        <sitefinity:Message ID="messageControl" runat="server" FadeDuration="3000" />
        <ol class="sfnewsletterFieldsList">
            <li class="sfnewsletterField">
                <asp:Label ID="emailAddressLabel" runat="server" Text='<%$Resources:NewslettersResources, EmailAddress %>' AssociatedControlID="emailAddress" CssClass="sfTxtLbl" />
                <asp:TextBox ID="emailAddress" runat="server" CssClass="sfTxt" />
                <asp:RequiredFieldValidator ID="emailValidator" runat="server" ControlToValidate="emailAddress" CssClass="sfErrorWrp" Display="Dynamic">
                    <strong class="sfError">
                        <asp:Literal runat="server" ID="lEmailIsRequired" Text='<%$Resources:NewslettersResources, EmailIsRequired %>' /></strong>
                </asp:RequiredFieldValidator><asp:RegularExpressionValidator
                    ID="emailRegExp"
                    runat="server"
                    ControlToValidate="emailAddress"
                    ValidationExpression="[a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,4}"
                    Display="Dynamic"
                    CssClass="sfErrorWrp"
                    ErrorMessage="<%$ Resources:ErrorMessages, EmailAddressViolationMessage %>">
                    <strong class="sfError">
                        <asp:Literal ID="lEmailNotValid" runat="server" Text="<%$ Resources:ErrorMessages, EmailAddressViolationMessage %>" /></strong>
                </asp:RegularExpressionValidator></li><li class="sfnewsletterField">
                <asp:Label ID="firstNameLabel" runat="server" Text='<%$Resources:NewslettersResources, FirstNamePublicForm %>' AssociatedControlID="firstName" CssClass="sfTxtLbl" />
                <asp:TextBox ID="firstName" runat="server" CssClass="sfTxt" />
            </li>
            <li class="sfnewsletterField">
                <asp:Label ID="lastNameLabel" runat="server" Text='<%$Resources:NewslettersResources, LastNamePublicForm %>' AssociatedControlID="lastName" CssClass="sfTxtLbl" />
                <asp:TextBox ID="lastName" runat="server" CssClass="sfTxt" />
            </li> 
            <li>
            <%--<br /> 
            <div class="g-recaptcha" data-sitekey="6LfNuhgTAAAAAHoVGH51Vs3iYNRb2Dual2_8Tv26"></div>
            <br/>--%>
            <asp:Label ID="lblMsg" runat="server" Visible="false" CssClass="sfTxt" />
    </li>      
        </ol>
        <div class="sfnewsletterSubmitBtnWrp">
            <asp:Button ID="subscribeButton" 
                runat="server" Text='<%$Resources:NewslettersResources, SubscribeToList %>' 
                CssClass="sfnewsletterSubmitBtn" onclick="subscribeButton_Click" /></div>
    </fieldset>
     <asp:Panel ID="selectListInstructionPanel" runat="server">
        <asp:Literal ID="pleaseSelectList" runat="server" Text='<%$Resources:NewslettersResources, ClickEditAndSelectList %>' />
    </asp:Panel>

     

  2. Sabrie Nedzhip
    Sabrie Nedzhip avatar
    534 posts
    Registered:
    28 Sep 2016
    11 Mar
    Link to this post
    Hi Rupali,

    Please check the below KB article for more details about how to extend the subscribe widget and add a captcha control

    http://www.sitefinity.com/developer-network/knowledge-base/details/extend-subscribe-form-widget-with-server-side-captcha-validation

    You may also check the below forum post where I have added some additional details on how to implement it and also have attached a video demonstrating the exact steps;

    http://www.sitefinity.com/developer-network/forums/bugs-issues-/captcha-in-subscribe-widget#RgbJGkiYP0WgqoyIbjeE5g

    Regards,
    Sabrie Nedzhip
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  3. rupali
    rupali avatar
    14 posts
    Registered:
    08 Mar 2016
    14 Mar in reply to Sabrie Nedzhip
    Link to this post
    Thank You for your reply...I will try this solution.
3 posts, 0 answered