Rules enable users to perform some types of actions.
Aspose.Form for .NET currently supports four types of actions:
- Assignment Action
- Dialog Box Message Action
- Switch View Action
- Query Action
These actions may be fired by the following types of events:
- Change control content event
- Click event
- Load form event
A Submit event is not supported yet.
Rules feature is supported for the following controls:
- Bulleted List
- Button
- Check Box
- List Box
- Drop-Down List Box
- File Attachment
- Numbered List
- Plain List
- Option Button
- Text Box
- Combo Box
- Date Picker
- Inc Picture
Aspose.Form for .NET also provides the ability to capture pre and post events for the actions e.g.
- RuleSetPreExecute event
- RuleSetPostExecute event
The example below shows how to capture the event, determine the type of the action and display the message accordingly.
Example
[C#]
protected void XmlFormView1_RuleSetPostExecute(object sender, EventArgs e)
{
if (sender is SwitchViewAction)
{
SwitchViewAction SwitchView = (SwitchViewAction)sender;
lblInfo.Text += "- Switch View Action has been finished.(Rule has changed the view to '" + SwitchView.View + "' )<br>";
}
else if (sender is AssignmentAction)
{
AssignmentAction Assignment = (AssignmentAction)sender;
if (Assignment.SimpleValue)
{
lblInfo.Text += "- Assignment Action has been finished.(Rule has changed the value to'" + Assignment.Expression + "' )<br>";
}
else
{
lblInfo.Text += "- Assignment Action has been finished.(Rule has changed the value from XPath'" + Assignment.Expression + "' )<br>";
}
}
else if (sender is DialogBoxMessageAction)
{
DialogBoxMessageAction DialogBox = (DialogBoxMessageAction)sender;
lblInfo.Text += "- Dialog Box Message Action has been finished.(Rule has displayed the message'" + DialogBox.Message + "' )<br>";
}
}
[VB.NET]
Protected Sub XmlFormView1_RuleSetPostExecute(ByVal sender As Object, ByVal e As EventArgs)
If TypeOf sender Is SwitchViewAction Then
Dim SwitchView As SwitchViewAction = CType(sender, SwitchViewAction)
lblInfo.Text &= "- Switch View Action has been finished.(Rule has changed the view to '" & SwitchView.View & "' )<br>"
ElseIf TypeOf sender Is AssignmentAction Then
Dim Assignment As AssignmentAction = CType(sender, AssignmentAction)
If Assignment.SimpleValue Then
lblInfo.Text &= "- Assignment Action has been finished.(Rule has changed the value to'" & Assignment.Expression & "' )<br>"
Else
lblInfo.Text &= "- Assignment Action has been finished.(Rule has changed the value from XPath'" & Assignment.Expression & "' )<br>"
End If
ElseIf TypeOf sender Is DialogBoxMessageAction Then
Dim DialogBox As DialogBoxMessageAction = CType(sender, DialogBoxMessageAction)
lblInfo.Text &= "- Dialog Box Message Action has been finished.(Rule has displayed the message'" & DialogBox.Message & "' )<br>"
End If
End Sub