How do I trigger WorkflowGen SubmitToWorkflow from a user control?



How do I trigger WorkflowGen SubmitToWorkflow from a user control?


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 webform. Assuming there is a user control UserCtrl1 (with and 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:

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) 

In the main aspx.cs page, under Page_load:

//----- 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:

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

In short, the sequence is as follows:

  • uc1.btnSubmit is clicked
  • btnSubmit_Clicked is triggered
  • trigger btnUserCtrlSubmitHandler event handler
  • relay event type btnUserCtrlSubmitHandler to uc1\_btnUserCtrlSubmitHandler
  • call SubmitToWorkflow()