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;