DocActionEvent object is Null ???? - InfoPath Dev
in

InfoPath Dev

DocActionEvent object is Null ????

Last post 06-25-2008 09:16 AM by Greg Collins. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 06-20-2008 09:41 AM

    DocActionEvent object is Null ????

    Hi there,

    I've added an event to a button of my created toolbar, as below

    [InfoPathEventHandler(MatchPath="btnCancel",EventType=InfoPathEventType.OnC­lick)]
            public void btnCancel_Click(DocActionEvent e)
            {
                   e.ReturnStatus = false;
            }

    I got error at this point saying that "Object reference not set"
    NOTE: This event is fired when I click on the button of that toolbar.
    The problem is that "e" object is not instantiated or set.
    The toolbar is created using below code:

    <xsf:toolbar caption="Testing" name="Testing Toolbar">
        <xsf:button name="btnTest" caption="Testing Button"></xsf:button>
    </xsf:toolbar>

    [InfoPathEventHandler(MatchPath="btnTest",EventType=InfoPathEventType.OnCli­ck)]
    public void btnTest_OnClick(DocActionEvent e)
    {
    -------------------

     

    }

     

    Any suggestions???

    Thanks

    Filed under: ,
  • 06-20-2008 03:58 PM In reply to

    Re: DocActionEvent object is Null ????

    A custom toolbar button does not use the same function syntax as a form button does.

    I haven't done these for a while, but if I recall correctly, you just need to create a public function of the same name as the toolbar button name, no parameters:

    public void btnTest()
    {
    ...
    }

  • 06-20-2008 05:39 PM In reply to

    Re: DocActionEvent object is Null ????

    Thanks Greg!!
    What if I want to check something and then I want to stop the button action.
    For example:

            public void btnCancel_Click(DocActionEvent e)
            {
                   e.ReturnStatus = false;
            } 

    The "e" will return false so that the button's event will be stopped.

    Anyways that I can do the same thing???

  • 06-23-2008 03:30 PM In reply to

    Re: DocActionEvent object is Null ????

    Since there is no event object, and the function returns void, whenever you want to stop processing the button click, just do a "return;".

  • 06-25-2008 09:01 AM In reply to

    Re: DocActionEvent object is Null ????

    Well, I tried using the "return" keyword. It surely stopped the process of other commands underneath it. But somehow, that's not what I want.
    If we have the DocAction object, we can just set it to "false", then other commands underneath it are still able to process until the end. Then, because of setting the DocAction object to "false",
    The commandBar onClick will stop processing.

    The intention behind this is that i write another method to hook up with the existed toolbar. Once the user click that commandBar button, they are supposed to execute my code from my method first. Once they get out from my method, the other code (dont know where it is, and don't wanna care about it as well since it's abstracted from being known) which is written for that commandBar button will be executed. If I am able to set the DocAction object to "false", I would be able to stop the process of that button right after it finishes running code in my method (so that it will not execute the other code which is written somewhere else).

    So, any suggestion??? :(

    Thanks

  • 06-25-2008 09:16 AM In reply to

    Re: DocActionEvent object is Null ????

    I'm not sure what this other code is you refer to. As I understand it, when you "create" a custom toolbar button, you process it as we describe. That's it. Nothing else runs. Now I don't know everything about custom toolbars, so maybe there's some process of running some other code. In that case, here's my suggestion. Set some value in a secondary DOM indicating the success status of your button code. Then when the other code runs, it can check the value of that secondary DOM node to see what it should do. But I'm not so sure that there is going to be any other code running--though I could be wrong.

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