Programmatically raising a infopath button click event - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Programmatically raising a infopath button click event

Last post 05-26-2014 12:03 AM by Rommel Sta. Juana. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 03-03-2010 10:07 AM

    • bubzo
    • Not Ranked
    • Joined on 03-03-2010
    • Posts 2

    Programmatically raising a infopath button click event

    I am trying to programmatically raise a infopath button click event from code behind. Is there any way this can be done?

    Here's what the situation is

    1.This is for a Web-based form app

    2. I have two buttons A and B, each has their rules and code behind

    3. On clicking of button A, (after its rules and code behind are run) I need to programmatically simulate click of button B

    4. Just calling the eventhandler of B from A doesn't work since I also need to run the rules associated with A.

     

    Any help would be greatly appreciated.

     

    Here's what I wanted to try but didn't work

    Call the OnClick method of button B from the event handler of button A using reflection. 

    However, I wasn't able to a) figure out

    a) how to manufacture the DocActionEvent paramter that OnClick wants (since the eventhandler for button B doesn't contain a proto that I could clone or something, instead it contains sender and ClickableEventArgs)

    b) Not really sure who to create a Infopath Button Type to use in my code...

     

  • 03-10-2010 09:08 AM In reply to

    • bubzo
    • Not Ranked
    • Joined on 03-03-2010
    • Posts 2

    Re: Programmatically raising a infopath button click event

    Hi All

     Just in case anyone wanted to know. This, in probablity, can't be done. While doing this in ASP.NET is a breeze the same is not true. We have found alternative mechanisms to meet our functionality.

     Bubzo

     

     

  • 03-10-2010 09:21 AM In reply to

    Re: Programmatically raising a infopath button click event

     I'm sure the members here would appreciate it if you wouldn't mind sharing your solution, but here is one solution:

    Add a secondary XML data source with two fields: <ButtonA> and <ButtonB>

     For each of these fields, add two rules as the first two rules:

    1. Condition: <Current Field> is blank.  Action: Stop executing rules  (no actual actions)
    2. (No condition)  Action: Set <Current Field> to blank

    Now move all of Button A's rules to the <ButtonA> field beneath the above two rules, and do the same for ButtonB.

    Also move ButtonA and ButtonB's event handler code to the OnAfterChange events of the respective fields, and add a condition to the code to not do anything if the current field is blank.

    Remove the rules and event handler code from both buttons, and give each button the single rule to set its respective field to some non-blank value.

    Lastly, add code at the end of the <ButtonA> field's event handler to set the <ButtonB> field to some non-blank value.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 05-26-2014 12:03 AM In reply to

    Re: Programmatically raising a infopath button click event

     Hi Jimmy,

     Good day. I'm quite new to coding in Infopath. Do you have some time to explain the above. Thank you

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