4.0 Form Builder click event

Posted by Community Admin on 03-Aug-2018 21:09

4.0 Form Builder click event

All Replies

Posted by Community Admin on 03-Nov-2010 00:00

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

Posted by Community Admin on 04-Nov-2010 00:00

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

Posted by Community Admin on 24-Jan-2011 00:00

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.

Posted by Community Admin on 26-Jan-2011 00:00

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

Posted by Community Admin on 15-Jun-2011 00:00

Please ignore this!

Thanks!

Posted by Community Admin on 01-Aug-2011 00:00

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

Posted by Community Admin on 02-Aug-2011 00:00

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

Posted by Community Admin on 05-Aug-2011 00:00

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

Posted by Community Admin on 05-Aug-2011 00:00

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

Posted by Community Admin on 11-Aug-2011 00:00

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

Posted by Community Admin on 12-Aug-2011 00:00

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

Posted by Community Admin on 12-Aug-2011 00:00

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

Posted by Community Admin on 18-Aug-2011 00:00

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

Posted by Community Admin on 19-Aug-2011 00:00

Useful coding given here. This is useful for me to to some extent.

This thread is closed