I'm sorry if this has been answered before, but please let me know where I can find the answer.
I am trying to change a field after a signature is added to a form.
Getting: "InvalidOperationException was unhandled by user code", "Operation is not valid, because of the current state of the object."
Code:
public void InternalStartup()
{
EventManager.XmlEvents["/my:myFields/my:signatures1/my:signatures2"].Changed += new XmlChangedEventHandler(signatures2_Changed);
}
public void signatures2_Changed(object sender, XmlEventArgs e)
{
// Write your code here to change the main data source.
XPathNavigator xnDoc = this.MainDataSource.CreateNavigator();
// MessageBox.Show(xnDoc.OuterXml.ToString(), "Main Data Source XML");
XPathNavigator field1 = xnDoc.SelectSingleNode("/my:myFields/my:field1", this.NamespaceManager);
if (field1.MoveToAttribute("nil", "http://www.w3.org/2001/XMLSchema-instance"))
field1.DeleteSelf();
field1.SetValue("true");
xnDoc = null;
field1 = null;
Thanks in advance.