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:
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
:
//----- 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 -
btnUserCtrlSubmitHandler
event handler is triggered -
btnUserCtrlSubmitHandler
event type is relayed to touc1_btnUserCtrlSubmitHandler
-
SubmitToWorkflow()
is called