Microsoft Office Tutorials and References
In Depth Information
Control events
If the code detects an error, InfoPath rejects the user's changes and restores the data
to its previous state. Here's an example:
public void myYearsOfExperience_Changing(object sender,
XmlChangingEventArgs e)
string strYearsOfExp = e.Site.SelectSingleNode("..
/my:myYearsOfExperience", NamespaceManager).InnerXml;
if (strYearsOfExp == string.Empty || strYearsOfExp == "")
e.CancelableArgs.Message = "Please enter a valid input";
e.CancelableArgs.Cancel = true;
Validating event
The InfoPath Validating event displays a prompt (if an error is found) before the
form has finished loading.
fieldname_Validating(object sender, XmlValidatingEventArgs e)
In other words, the Validating event is normally used more for error handling in
the InfoPath form, as compared to the data validation of the InfoPath form.
public void Name_Validating(object sender, XmlValidatingEventArgs e)
XPathNavigator xNode = this.CreateNavigator().
this.Errors.Add(xNode, "Name to validate..", "error occured",
"Correct the error");
Control events
InfoPath supports only one event when a button control is activated. The Clicked
event is activated when a button control on a form is clicked, and is used to display
a message to the user.
Clicked event
The following code uses the Clicked event to display the date and time when the
user clicks on a particular button:
ButtonName_Clicked(object sender, ClickedEventArgs e)
Search JabSto ::

Custom Search