EventManager.XmlEvents["..."].Changed event not recognized in MOSS !? - InfoPath Dev
in

InfoPath Dev

EventManager.XmlEvents["..."].Changed event not recognized in MOSS !?

Last post 09-08-2009 09:49 AM by danirrivas. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 11-10-2008 01:30 AM

    • davex
    • Not Ranked
    • Joined on 11-04-2008
    • Posts 8

    EventManager.XmlEvents["..."].Changed event not recognized in MOSS !?

    Hello,

     I'm quite new to the world of InfoPath and SharePoint so my apologies if this question sounds a little bit "newbie" !

     I'm making a form that will be integrated to our MOSS 2007 solution. Outside MOSS, in the InfoPath client preview, everything's alright and act like expected. But when I publish/upload my form into MOSS, the event of having modified (change) a datetime form field seems to be not recognized. Here's the code :

    using Microsoft.Office.InfoPath;
    using System;
    using System.Xml;
    using System.Xml.XPath;
    using System.Collections.Generic;
    using System.Text;
    using System.Globalization;

    namespace Demande_Conge
    {
        public partial class FormCode
        {
            public void InternalStartup()
            {
                EventManager.FormEvents.Loading += new LoadingEventHandler(FormEvents_Loading);
                EventManager.XmlEvents["/my:DemandeConge/my:Conges/my:DateFin"].Changed += new XmlChangedEventHandler(DateFin_Changed); <== this event is not recognized as the "DateFin_Changed" function isn't executed.
            }

            public void FormEvents_Loading(object sender, LoadingEventArgs e)
            {
                XPathNavigator MainData = MainDataSource.CreateNavigator();

                MainData.SelectSingleNode("/my:DemandeConge/my:IDDemande", NamespaceManager).SetValue(
                            MainData.SelectSingleNode("/my:DemandeConge/my:Employe", NamespaceManager).Value + "_" + DateTime.Now.ToShortDateString());
               
            }

            public void DateFin_Changed(object sender, XmlEventArgs e)
            {
                XPathNavigator MainData2 = MainDataSource.CreateNavigator();

                DateTime dt1 = MainData2.SelectSingleNode("/my:DemandeConge/my:Conges/my:DateDebut", NamespaceManager).ValueAsDateTime;
                DateTime dt2 = MainData2.SelectSingleNode("/my:DemandeConge/my:Conges/my:DateFin", NamespaceManager).ValueAsDateTime;

                System.TimeSpan span = dt2.Subtract(dt1);

                double final = span.TotalDays;
                string final2 = final.ToString();

                MainData2.SelectSingleNode("/my:DemandeConge/my:Conges/my:Total", NamespaceManager).SetValue(final2);
            }

        }
    }

    So what's wrong in this code ? What annoys me is that it works perfectly outside MOSS... :'(

     Thanks a lot for your help.

     David from Belgium.

  • 11-10-2008 11:22 PM In reply to

    • Shiva
    • Top 25 Contributor
    • Joined on 04-15-2005
    • India
    • Posts 694

    Re: EventManager.XmlEvents["..."].Changed event not recognized in MOSS !?

    Hello,

    Did you changed any thing in InternalStartup() function code? DateFin field changed event automatically generates when we double click on that field. After generating this event did you try to modify it?

    Otherwise can remove the existing event and try to create new event and copy the existing code to that function then try to execute and check once still getting the error?

  • 11-11-2008 11:42 PM In reply to

    • davex
    • Not Ranked
    • Joined on 11-04-2008
    • Posts 8

    Re: EventManager.XmlEvents["..."].Changed event not recognized in MOSS !?

    Hi Shiva ! Thanks for your answer.

     Unfortunately, I haven't modified anything to the "changed" event of my DateFin field. I did try to remove it and generate it again but nothing changes: the event seems to be unknown once I load the form in SharePoint....

    Any ideas ?

     Thanks a lot.

  • 11-11-2008 11:53 PM In reply to

    • davex
    • Not Ranked
    • Joined on 11-04-2008
    • Posts 8

    Re: EventManager.XmlEvents["..."].Changed event not recognized in MOSS !?

    I finally found why the event handler wasn't working : you must set the post back option to "Always" on the Browser Forms tab of the Properties dialog box for the list box.

    Thanks !

  • 09-08-2009 09:49 AM In reply to

    • danirrivas
    • Not Ranked
    • Joined on 07-13-2009
    • Barcelona, Spain
    • Posts 6

    Re: EventManager.XmlEvents["..."].Changed event not recognized in MOSS !?

    Thanks a lot davex. I was having the same problem as you... not anymore XD XD

Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.