# How do I trigger WorkflowGen SubmitToWorkflow from a user control?

**URL:** <https://discuss.workflowgen.com/t/how-do-i-trigger-workflowgen-submittoworkflow-from-a-user-control/213>\
**Category:** Visual Studio Web Forms\
**Created:** [October 13, 2011, 1:00am UTC](https://discuss.workflowgen.com/t/how-do-i-trigger-workflowgen-submittoworkflow-from-a-user-control/213 "2011-10-13T01:00:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wfg-admin](https://yyz2.discourse-cdn.com/flex030/user_avatar/discuss.workflowgen.com/wfg-admin/32/714_2.png) [@wfg-admin](https://discuss.workflowgen.com/u/wfg-admin)\
**Post date:** [October 13, 2011, 1:00am UTC](https://discuss.workflowgen.com/t/how-do-i-trigger-workflowgen-submittoworkflow-from-a-user-control/213/1 "2011-10-13T01:00:05Z")

</div>

**Issue**

How do I trigger WorkflowGen `SubmitToWorkflow` from a user control?

**Solution**

To trigger the WorkflowGen `SubmitToWorkflow` from a user control you will need to set up delegate and event declaration to associate the button in your user control to communicate with the `SubmitToWorkflow` method in the main web form. Assuming there is a user control `UserCtrl1` (with an instance ID `uc1` used on the main `aspx` page) and inside the user control there is a button called `btnSubmit`.

In your UserControl `ascx.cs` page:

```auto
public partial class UserCtrl1 : System.Web.UI.UserControl{ 
 // Delegate declaration 
 public delegate void OnSubmitButtonClick(string strValue);
  // Event declaration 
 public event OnSubmitButtonClick btnUserCtrlSubmitHandler;

 /// <summary> 
 /// in case of the submit button in user control is clicked, 
 /// trigger the SubmitButtonClick event that reference to 
 /// UserCtrl1_btnUserCtrlSubmitHandler event on the main page 
 /// </summary> 
 protected void btnSubmit_Click(object sender, EventArgs e) { 
 //---- call the event handler 
 if (btnUserCtrlSubmitHandler != null) 
  { 
   btnUserCtrlSubmitHandler(string.Empty); 
  }
 }
}

```

In the main `aspx.cs` page, under `Page_load`:

```auto
//----- this is to add an event handler that allow user to call SubmitToWorkflow(); 
uc1.btnUserCtrlSubmitHandler += new UserCtrl1.OnSubmitButtonClick(uc1_btnUserCtrlSubmitHandler);

```

Under the partial class of the main `aspx.cs` page, add the handler:

```auto
void uc1_btnUserCtrlSubmitHandler(string strValue){ SubmitToWorkflow(); }

```

In short, the sequence is as follows:

1. `uc1.btnSubmit` is clicked
2. `btnSubmit_Clicked` is triggered
3. `btnUserCtrlSubmitHandler` event handler is triggered
4. `btnUserCtrlSubmitHandler` event type is relayed to to `uc1_btnUserCtrlSubmitHandler`
5. `SubmitToWorkflow()` is called
