More in this section
Forums / Developing with Sitefinity / Inbuilt form with custom forms widget + widget designer

Inbuilt form with custom forms widget + widget designer

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
2 posts, 0 answered
  1. Quba
    Quba avatar
    15 posts
    13 Jun 2006
    30 Jan 2014
    Link to this post

    I'm trying to create a custom submit button for a built in form.

    I'm using this control:
    <sf:FormSubmitButton runat="server" ID="btSubmit" Text="Submit" CssClass="submitButton" /> 

    I need to attach a custom onclick attribute to the button for google event tracking. But I still need the onclick attribute given by the built in submit button for the form to return.

    The custom onclick attribute needs to be built up from fields in the widget designer and I have managed to get this working as follows:

    <input type="submit" name="ctl00$ctl00$cphBaseBody$LeftColumn$C001$ctl00$ctl00$C019$ctl00$ctl00$btSubmit" value="Submit" onclick="_gaq.push(['_trackEvent', 'Videos', 'Play', 'Baby\'s First Birthday']);" id="cphBaseBody_LeftColumn_C001_ctl00_ctl00_C019_ctl00_ctl00_btSubmit" class="submitButton">

    This was done like this:

     protected override void InitializeControls(GenericContainer container)
                this.btSubmit.Attributes.Add("onclick", string.Format("_gaq.push(['_trackEvent', '{0}', '{1}', '{2}']);", Category, Action, Label));


    (where category, action and label are custom fields in the designer)

    However, I need the following onclick attribute for the form to go to the correct page when I hit submit:

    onclick="return Telerik.Sitefinity.Web.UI.Fields.FormManager.validateGroup(&quot;sf_getaquoteC005&quot;);" 

    How do I access that attribute?

    Kind regards,

    Sophie Baxter 
  2. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    18 Sep 2017
    04 Feb 2014
    Link to this post
    Hello Sophie, 

    Subscribe to the click event of the form button using javascript widget placed on the page where the form is placed placing the below javascript in the javascript widget.

    In the javascritp widget please make sure to select the radio button option "Before the closing body tag"

    $('input[type=submit]').click(function() {
    //execute function here

    Stanislav Velikov
    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
2 posts, 0 answered