More in this section

Forums / Developing with Sitefinity / Sending Form Data to External Database?

Sending Form Data to External Database?

2 posts, 0 answered
  1. John
    John avatar
    26 posts
    Registered:
    10 Sep 2012
    15 Dec 2012
    Link to this post
    Hi everyone,

    How do I send form data to an external database of MS SQL? I do not want the form data to go to the Sitefinity database upon submit. Can the forms widget be more expansive in functionality? It seems too limited to only send data to the Sitefinity database. Is anyone else running into this issue? What documentation is available on this topic?

    I appreciate any help and guidance that can be offered. Thank you,

    Maria
  2. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    15 Dec 2012 in reply to John
    Link to this post
    It's actually pretty easy

    Create a new class and inherit from the existing forms control

    public class FormsControlCustom : FormsControl

    This inside of Initialize controls you can hook into the Save events and do whatever custom code you want to put the data somewhere else.

    protected override void InitializeControls(GenericContainer container)
            {
                if (!SystemManager.IsDesignMode)
                {
                    //Hide the form if JS is disabled, it'll let them bypass the required fields.
                    base.InitializeControls(container);
                    this.BeforeFormSave += new EventHandler<CancelEventArgs>(FormsControlCustom_BeforeFormSave);
                }
            }
2 posts, 0 answered