MessageBox don't work - InfoPath Dev
in

InfoPath Dev

MessageBox don't work

Last post 07-06-2007 08:27 AM by stevanus.hk. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 12-04-2006 02:09 AM

    MessageBox don't work

    Hi all

    I've created a browser enabled workflow. I use VSTA c# code to manage my template. At several code parts I need to show up a MessageBox. The design checker reports me, that there are unsupproted features in the code. After debugging I figured out, that my MessageBoxes aren't supported. The error message says I shold remove System.Windows. Forms.

    How can I trow exeptions or alerts in the browser? If it is possibele answer with code example.
    Thx
  • 12-05-2006 05:00 PM In reply to

    MessageBox is supported. Something else must be going on here.
  • 07-02-2007 02:13 AM In reply to

     

    Hello Greg,

    Even i am facing the same error. When i use MessageBox of  System.Windows.Forms in my browser enabled infopath forms, i too get the same error. i.e. Unsupported feature in code. and when i click on this "Unsupported feature in code", it shows me a dialog box saying "User interface operations are not supported. Consider removing  the follwing usage : System.Windows.Forms"

    Please help... 

     

     

     

     

     

     

  • 07-02-2007 04:33 AM In reply to

    Hi, I actually have never worked with browser enabled form but you could try to write your own small assembly which implements windows.forms. Code a small method to which you can pass a string value (message you want to pop up). Now in your infopath project add your created .ddl as a reference and call the "shwomessage" method everytime you need one.

    could this work ?

    Listen to Motörhead cos they play Rock'n Roll :)
  • 07-02-2007 05:30 AM In reply to

    I just tried it with a usual (not browser enabled) InfoPath form and it works. Here a little walkthrough, if you want you can give it a try. Open Visual Studio, click new project and Select "Class Library". Below the code for the library: using System; using System.Windows.Forms; namespace MessagePopUp { public class PopUp { public PopUp() { } public void ShowMessage(string strMessage) { MessageBox.Show(strMessage); } } Compile it. In the bin/debug folder of the project you can now find a .ddl file. In your infopath solution add a reference (browse to the ddl). from within a button onClick or onAfterChange event of your form you can then call the ShowMessage() method. Can you let us know if this works ? Sorry for the format. Somehow it doesn't work anymore in a better way
    Listen to Motörhead cos they play Rock'n Roll :)
  • 07-02-2007 09:22 AM In reply to

    Thank you for sharing this!
  • 07-02-2007 09:25 AM In reply to

    The problem with Browser-Enabled Forms is that your code runs entirely on the server. As such, there is no way you can show a WinForms messagebox: even if you succeed, no one will ever see it.

    Your best is to implemented modeless UI in the form intself using conditional formatting by showing/hiding an section in your form that contains the error. This is not ideal (you cannot block the rest of the form) but it's pretty much the only solution for browser-enabled forms (for all practical purposes).

    Of course once you have a conditionally formatted section you can control its appearance with either code or rules/default values. Please be aware that since all code runs on the server side, using code for this will require your form to send data to the server which will decrease its performance.

    Hope this clarifies the issue!

    David Airapetyan / Software Services Architect
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 07-03-2007 04:37 AM In reply to

    I guess david is right but anyway i just wanna come up with another possible solution. One thing up front... sorry for the format of my post and also this is really only a simply example. The idea is to create a .hta file. Just open a new textfile and copy this code into it: html head title title hta:application id="MyApp" applicationName="My Application" border="thick" borderStyle='sunken' caption='yes' contextMenu='yes' icon='' innerBorder='yes' maximizeButton='yes' minimizeButton='yes' navigable='no' scroll='yes' scrollFlat='no' selection='yes' showInTaskBar='yes' singleInstance='no' sysMenu='yes' version='1.0' windowState='normal' head body script language = JavaScript document.write(MyApp.commandLine); script body html Now save this file as Test.hta into you C:\\temp folder. from within a button event in your infopath form you can then call this hta file to popup and pass the Alert message you require. var shell = new ActiveXObject('WScript.Shell'); shell.Run('mshta.exe ' + 'C:\\temp\\Test.hta' + 'ALERT TEXT', 6); There is of course on disatvantage, you need to deploy the hta file to every users machine so that you can call it. At the moment also the popup appears behind the currently opened infopath form but i guess there are attributes to change that. As I said just a rough example as I haven't worked with this a lot yet. Just sharing some ideas.
    Listen to Motörhead cos they play Rock'n Roll :)
  • 07-06-2007 08:27 AM In reply to

    you can use section with and show the section when you want to show your alert, or use view and switch between view
Page 1 of 1 (9 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.