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

Forums / Developing with Sitefinity / SF 3.5 Newsletter Control

SF 3.5 Newsletter Control

5 posts, 0 answered
  1. Mike
    Mike avatar
    7 posts
    Registered:
    13 Nov 2008
    27 Jan 2009
    Link to this post
    Hi,

    /Sitefinity/ControlTemplates/SubscriptionFormTemplate.ascx which is used in the Newsletter "Subscription Form" toolbox control does not seem to have server side validation built in. When I try to handle validation server side I get a "...is inaccessible due to its protection level" error.

    So my question is how can I add server side validation to this control file?

    Thanks,

    Mike
  2. Parvan
    Parvan avatar
    151 posts
    Registered:
    24 Sep 2012
    30 Jan 2009
    Link to this post
    Hello Mike,

    Thank you for contacting us.

    1. By default validation is done on client side. To disable it and allow the server side validation you must set this attribute to all validators in the template /Sitefinity/ControlTemplates/SubscriptionFormTemplate.ascx :

     <asp:RequiredFieldValidator ID="emailEmptyValidator2" runat="server" CssClass="sf_emailValidation"   
    EnableClientScript="false" 
    ValidationGroup="subscription" ControlToValidate="sf2_email" Display="Dynamic" 
    EnableViewState="False" SetFocusOnError="True">  
    <strong><asp:Literal ID="Literal7" runat="server" Text="Email cannot be empty!"></asp:Literal></strong>  
    </asp:RequiredFieldValidator> 

    To complete the server validation you must add a check for Page.IsValid in the server code. Currently there is no easy way to plug into the SubscriptionForm code, but for the upcoming release of Sitefinity 3.6 (the release is coming soon) we will add such possibility.
    So the better way is to upgrade to the new version 3.6 when it is released and then:
    2. Add the class CustomSubsciptionForm.cs (attached in this response) to your site App_Code.
    3. Add this line in the toolboxControls section of your site's web.config file:
    <toolboxControls> 
    ...  
        <add name="Custom Subscriber Form" section="Newsletters" type="Telerik.Notifications.Newsletters.WebControl.CustomSubscriptionForm, App_Code" description="SubscriptionForm with server validation"/>  
    </toolboxControls> 

    Then just use the "Custom Subsciption Form" control instead of  "Subscription Form" control in the toolbox for Newsletters.

    Hope this information will help you.

    Best wishes,
    Parvan
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    30 Jan 2009
    Link to this post
    Hello Mike,

    Thank you for contacting us.

    1. By default validation is done on client side. To disable it and allow the server side validation you must set this attribute to all validators in the template /Sitefinity/ControlTemplates/SubscriptionFormTemplate.ascx :

     <asp:RequiredFieldValidator ID="emailEmptyValidator2" runat="server" CssClass="sf_emailValidation"   
    EnableClientScript="false" 
    ValidationGroup="subscription" ControlToValidate="sf2_email" Display="Dynamic" 
    EnableViewState="False" SetFocusOnError="True">  
    <strong><asp:Literal ID="Literal7" runat="server" Text="Email cannot be empty!"></asp:Literal></strong>  
    </asp:RequiredFieldValidator> 

    To complete the server validation you must add a check for Page.IsValid in the server code. Currently there is no easy way to plug into the SubscriptionForm code, but for the upcoming release of Sitefinity 3.6 (the release is coming soon) we will add such possibility.
    So the better way is to upgrade to the new version 3.6 when it is released and then:
    2. Add the class CustomSubsciptionForm.cs (attached in this response) to your site App_Code.
    3. Add this line in the toolboxControls section of your site's web.config file:
    <toolboxControls> 
    ...  
        <add name="Custom Subscriber Form" section="Newsletters" type="Telerik.Notifications.Newsletters.WebControl.CustomSubscriptionForm, App_Code" description="SubscriptionForm with server validation"/>  
    </toolboxControls> 

    Then just use the "Custom Subsciption Form" control instead of  "Subscription Form" control in the toolbox for Newsletters.

    Hope this information will help you.

    Best wishes,
    Georgi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  4. Mike
    Mike avatar
    7 posts
    Registered:
    13 Nov 2008
    01 Feb 2009
    Link to this post
    Hi Georgi,

    I'll give this a try. Although I think I will go with what I ended up doing for another project which was buildling my own custom form with client and server side validation which then hooks into the SF API to create a new subscriber.

    Cheers,

    Mike.
  5. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    02 Feb 2009
    Link to this post
    Hi Mike,

    This is also an option. I am glad you have managed to find a way for that.

    Best wishes,
    Georgi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Register for webinar
5 posts, 0 answered