using VSTA in InfoPath in a browser form - InfoPath Dev
in

InfoPath Dev

using VSTA in InfoPath in a browser form

Last post 10-24-2008 10:56 AM by Jimmy. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 10-23-2008 10:29 AM

    using VSTA in InfoPath in a browser form

    All I have added code in the load event of my infopath form, when an error occured i did have messagebox but you can not use that on a browser based form,

    *************** the questions is that if you add the text box to the form if will show up regardless if you have an error or not.Is there  a way to hide and show the text box based on if there is an error or not?

     

    i found this article: 

    Displaying error message for browser-enabled form template     Last Edit 8:34 PM by MarkRoberts   

    ChrisP123: The code examples do assume that you're opening the form in the InfoPath client. As you've discovered, System.Windows.Forms.MessageBox() is not supported for forms that can open in the browser. To display an error message in a web-based form on InfoPath Forms Services, you'd need to display the message in-line in the form itself.


    One way to do that, is to add a text field to the Main data source, eg named "ErrorMsg", drag that as a Text Box control on to the form, and then use code like the following in the try/catch block to write the error message to the ErrorMsg field:


    catch (Exception ex){   XmlNamespaceManager ns = this.NamespaceManager;
     

       XPathNavigator xnDoc = this.MainDataSource.CreateNavigator();
     

       xnDoc.SelectSingleNode("/my:myFields/my:ErrorMsg", ns).SetValue(
          "The following error occurred: " + ex.Message);
       throw;

  • 10-23-2008 03:35 PM In reply to

    • jrudolph
    • Top 150 Contributor
      Male
    • Joined on 07-02-2008
    • Orlando, FL
    • Posts 67

    Re: using VSTA in InfoPath in a browser form

    I dont know if this will actually answer your question, but have you tried simply using rules in conjunction with your text box?
  • 10-24-2008 10:56 AM In reply to

    Re: using VSTA in InfoPath in a browser form

    Yes, I would imagine you could use conditional formatting to hide the text box when /my:myFields/my:ErrorMsg is blank.

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