There are times you are designing a form and realize that it will require the same fields/data to be shown on

multiple pages of the form. To avoid having the user reenter this data multiple times, you can take advantage of the 'AfterSetData' event to cascade the data through all the pages. 

The implementation within this event can become even easier if the controls are named with following format, FieldName_Page#.

For example, lets say we require the same name at the top of the first 4 pages of a form. So we have have four controls named "Name_1", "Name_2", "Name_3", and "Name_4".

On the .NET side, the code would be as follows:



<MiCode(ControlScriptEventType.AfterSetData, "Name_1")> _ 
Public Sub Ctl_Name_1_AfterSetData(ByVal e As AfterSetDataEventArgs)
	'Loop through the rest of the pages with the fields
	For i As Integer = 2 To 4
		'Dynamically set the name of each field
		Dim name As String = "Name_" & i

		'Get the control/field by name and set its value to Name_1's value
		_form.GetFormControlByName(name).Value = e.Control.Value
End Sub


On the JavaScript side, the code would be as follows:


// Triggered when a field's value changes
function MFAfterSetData(fieldName) {
	if (fieldName == "Name_1"){
		var name = _form.getValue(fieldName);
		//Loop through the other fields on pages 2-4
		for (i = 2; i <= 4; i++) { 
			//Dynamically set the name of each field
    		var newField = "Name_" + i;
			//Set the value of each field using the initial value from Name_1
			_form.setValue(newField, name);


So here we can see to add this code to the AfterSetData event for 'Name_1', and loop through the rest of the pages with this field (2-4) and set their value.