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

Forums / General Discussions / 4.0 Form Builder click event

4.0 Form Builder click event

14 posts, 0 answered
  1. Joshua
    Joshua avatar
    10 posts
    Registered:
    18 Mar 2010
    03 Nov 2010
    Link to this post
    I have been  testing the beta form builder and had a question. Is there a way to capture the click event tied to the "submit" button?


    Thank you,
    Joshua
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    04 Nov 2010
    Link to this post
    Hello Joshua,

    You have to create a custom form control that inherits from FormsControl

    sample

    class Class5 : FormsControl
       {
           protected override void Submit_Click(object sender, EventArgs e)
           {
               base.Submit_Click(sender, e);
           }
       }

    Then you can include your custom widget from Settings >> Forms >> Controls.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Corby Bender
    Corby Bender avatar
    16 posts
    Registered:
    05 Jan 2010
    24 Jan 2011
    Link to this post
    Joshua, 

    Did you get this figured out?  I'm in the same boat...need to be able to tie into the built-in form builder submit button to update a database table upon submit...any details, the lengthier the better, that you'd be willing to share would be great.  Thanks in advance.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    26 Jan 2011
    Link to this post
    Hi,

    Here is a sample code that  shows how to subscribe for the click event of the button

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Telerik.Sitefinity.Modules.Forms.Web.UI;
    using Telerik.Sitefinity.Modules.Forms.Web.UI.Fields;
    using Telerik.Web.UI;
     
    namespace Telerik.Sitefinity.Samples
    {
        public class FormsControlCustom : FormsControl
        {
            protected override string LayoutTemplateName
            {
                get
                {
                    return FormsControlCustom.layoutTemplateName;
                }
            }
     
            protected override void ConfigureSubmitButton(System.Web.UI.Control control, string validationGroup)
            {
                 
                var submit = control as FormSubmitButton;
                submit.Click += new EventHandler(submit_Click);
                base.ConfigureSubmitButton(control, validationGroup);
     
            }
     
            void submit_Click(object sender, EventArgs e)
            {
                var list = this.FieldControls;
                
            }
     
     
         
     
            private const string layoutTemplateName = "Telerik.Sitefinity.Samples.Resources.FormsControl.ascx";
     
        }
    }


    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Duneel
    Duneel avatar
    166 posts
    Registered:
    08 Dec 2010
    15 Jun 2011
    Link to this post
    Please ignore this!

    Thanks!
  6. Tony
    Tony avatar
    29 posts
    Registered:
    30 Dec 2010
    01 Aug 2011
    Link to this post
    Where would I place this subscription code in the project? I would need to be able to access other custom form controls that I have made, specifically a radupload control that I will be using.

    Thanks,

    Tony
  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    02 Aug 2011
    Link to this post
    Hello Tony,

    The code above inherits from FormsControl which represents the Forms Widget in toolbox controls section. The widget allows you to select forms you created like the default one.
    You can register the custom widget following instructions provided here

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  8. Tony
    Tony avatar
    29 posts
    Registered:
    30 Dec 2010
    05 Aug 2011
    Link to this post
    I have no issue adding a control to the tool box. Is there any way I could get both the .ascx as well as the codebehind? I tried to place the control on a form page but was given an error saying that the control must extend  System.web.UI.UserControl.

    I also assume I will need the .js file as well.

    Thanks,

    Tony
  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    05 Aug 2011
    Link to this post
    Hi Tony,

    The code below should be added to a class library and you have to use the template below as an embedded resource

    <%@ Control Language="C#" %>
     
    <%@ Register TagPrefix="sfFields" Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI.Fields" %>
     
    <%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI" Assembly="Telerik.Sitefinity" %>
     
      
     
    <sfFields:FormManagerid="formManager"runat="server"/>
     
      
     
      
     
    <asp:PanelID="errorsPanel"runat="server"CssClass="sfErrorSummary"/>
     
    <sf:SitefinityLabelid="successMessage"runat="server"WrapperTagName="div"HideIfNoText="true"CssClass="sfSuccess"/>
     
    <asp:PanelID="formControls"runat="server">
     
          
     
    </asp:Panel>

    The javascript should be added by the base class.

    Regards,
    Ivan Dimitrov
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  10. Tony
    Tony avatar
    29 posts
    Registered:
    30 Dec 2010
    11 Aug 2011
    Link to this post
    Ivan,

    I believe I have the click event successfully being captured. I am using this to create a RadUpload control that users can place on a form. i am having issues with the validator for that upload. When the submit button is clicked any validator I place on the page along with the upload control dos not seem to be firing. I have worked around issues of detecting the file extension and rejecting files that are not allowed. However the maximum uploaded file size is not being validated when the submit occurs. I have the file size set and it appears to be working correctly as in any files that are lager than the MaxFileSize are not being uploaded, but the form still submits. Only the file portion is omitted. the user is never notified that the file never got uploaded. I can't check this via javascript because the file upload needs to start in order to detect a file size. I'd like to alert the user that the file is too large and not submit the rest of the form till it is corrected.

    <script type="text/javascript">
        function ClearInvalidInputs() {        
            var ul = $find("<%= ruFormDocs.ClientID %>");
            var inputs = ul.getFileInputs();
            for (i = inputs.length - 1; i >= 0; i--) {
                if (!ul.isExtensionValid(inputs[i].value)) {
                    alert('Only the .pdf, .jpg, .jpeg, .doc, .docx files are allowed');
                    ul.clearFileInputAt(i);
                }
            }
        }
    </script>

    <telerik:RadUpload ID="ruFormDocs" runat="server" 
        OnClientFileSelected="ClearInvalidInputs" 
        AllowedFileExtensions=".pdf,.jpg,.jpeg,.doc,.docx" 
        MaxFileSize="10485760" />

    Any ideas?

    Thanks,

    Tony
  11. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    12 Aug 2011
    Link to this post
    Hi Tony,

    Have you tried the sample from the official documentation of RadUpload control here?

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  12. Tony
    Tony avatar
    29 posts
    Registered:
    30 Dec 2010
    12 Aug 2011
    Link to this post
    Yes I have tried that. I have used the RadUpload many times but never within a Sitefinty 4 form with a custom form control that I need to use in order to perform some action on the submit button. I used the solution you listed above to create the custom form control. Putting that control on a form prompts me to select an already existing form. I have made one that only has a RadUpload on it. This actually nests the form controls. Is that how you intended your submit button solution to behave?

    Let me know if you would like me to zip the project and send it. I am using an empty Sitefinity site at the moment.

    Thanks,

    Tony
  13. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    18 Aug 2011
    Link to this post
    Hi Tony,

    Ok, send the project ( with the App_Data and its database ) and we will check it here. It looks like that there is an issue with the RadScriptManager and the way that the scripts are loaded.

    All the best,
    Ivan Dimitrov
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  14. Crystal
    Crystal avatar
    5 posts
    Registered:
    19 Aug 2011
    19 Aug 2011
    Link to this post
    Useful coding given here. This is useful for me to to some extent.
14 posts, 0 answered