How to upload an InfoPath file with C# code to SharePoint? RRS feed

  • 问题

  • I designed an InfoPath with Visual Studio 2008(C#), but after I uploaded it to SharePoint and finished all the necessary configurations, I could see none Controls related to the code.

    Here's the detail of my little lovely demo:

    View 1:1 File Attachment, 2 Fields(TextBoxes), 1 Button

    I add some code here for Button:

      public void InternalStartup()
       EventManager.FormEvents.Loading += new LoadingEventHandler(FormEvents_Loading);
       ((ButtonEvent)EventManager.ControlEvents["btnChange"]).Clicked += new ClickedEventHandler(btnChange_Clicked);
      public void btnChange_Clicked(object sender, ClickedEventArgs e)
       XPathNavigator root = MainDataSource.CreateNavigator();
       string valueFromTxt1 = root.SelectSingleNode("/my:myFields/my:txt1", NamespaceManager).Value;
       root.SelectSingleNode("/my:myFields/my:txt2", NamespaceManager).SetValue(valueFromTxt1);
       //Simply, I just wanna display the value of txt1 in txt2
    Hope I can get the powerful answer here.
    2010年12月15日 8:34