<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Code</title><link>https://www.infopathdev.com:443/forums/45.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Set a form field's value when a signature is removed (C#)</title><link>https://www.infopathdev.com:443/forums/thread/103733.aspx</link><pubDate>Wed, 26 Aug 2015 22:11:04 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:103733</guid><dc:creator>iAmMortos</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/103733.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=103733</wfw:commentRss><description>&lt;p&gt;I have a code block that detects when signatures (even a specific signature) is removed, and inside this block, I want to set some field values.&lt;/p&gt;

&lt;p&gt;Presently, I even know how to get and set field values using the &lt;code&gt;XPathNavigator&lt;/code&gt; class&amp;#39;s &lt;code&gt;.SetValue&lt;/code&gt; method.&lt;/p&gt;

&lt;p&gt;The problem comes in when I try to do both at the same time.&lt;/p&gt;

&lt;p&gt;I&amp;#39;m assuming that the user will be removing a signature through InfoPath&amp;#39;s built-in Digital Signature dialog box. The problem is, when a signature is removed this way, the modal dialog box is still open when the &lt;code&gt;.Changed&lt;/code&gt; trigger happens, thus preventing the fields from being changed, and throwing the error: &lt;code&gt;&amp;quot;Operation is not valid, because of the current state of the object.&amp;quot;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Is there some way to run the triggered code &lt;i&gt;after &lt;/i&gt;the dialog has been closed? Or perhaps close the dialog box &lt;i&gt;programmatically &lt;/i&gt;before setting the field values? &lt;br /&gt;&lt;/p&gt;</description></item></channel></rss>