How to code a changed text box? - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

How to code a changed text box?

Last post 03-25-2009 08:24 AM by Jimmy. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 03-24-2009 07:42 PM

    How to code a changed text box?

    I have a form that is going to be updated on a regular basis and I would like to be able to reflect the date a certain text box was last updated for use in a dashboard.  I have some C# experience but I'm not sure the best way to go about it.  I'm not sure if the 'Changed' event will be able to handle it or what.  Any guidance would be greatly appreciated (Infopath 2007)

    Filed under: , ,
  • 03-24-2009 08:40 PM In reply to

    Re: How to code a changed text box?

    Yes, putting something like this in the textbox's changed event would do the trick:

    XPathNavigator dateNode = MainDataSource.CreateNavigator().SelectSingleNode("XPath to date node", NamespaceManager);

    // Delete the xsi:nil attribute if it is present
    XPathNavigator nilAttribute = dateNode.SelectSingleNode("@xsi:nil", NamespaceManager);
    if (nilAttribute != null)
    {
         nilAttribute.DeleteSelf();
    }

    dateNode.SetValue(
    XmlConvert.ToString(DateTime.Now,"yyyy-MM-dd"));

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 03-25-2009 08:14 AM In reply to

    Re: How to code a changed text box?

    Looks like it worked just fine, thank you very much - do you know of a good site or book to explain working with XML and C#?  My C# is a littel rusty but I have very little experience coding with XML

  • 03-25-2009 08:24 AM In reply to

    Re: How to code a changed text box?

    I don't, unfortunately, but I learned almost all of what I know just by tinkering around a lot.  For coding with XML in InfoPath, reading the up on the XPathNavigator class will get you a long way.  It's nearly the only XML-related class you'll need to use with InfoPath, and by far the most important methods are SelectSingleNode() and Select():

    http://msdn.microsoft.com/en-us/library/system.xml.xpath.xpathnavigator.aspx
    http://msdn.microsoft.com/en-us/library/bb509311.aspx
    http://support.microsoft.com/kb/308343

    It's a bit dry, but I'd also suggest reading the W3C document on XPath.  It illuminates a lot of XPath's capabilities:

    http://www.w3.org/TR/xpath

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.