Button OnClick Event - InfoPath Dev
in

InfoPath Dev

Button OnClick Event

Last post 02-25-2007 11:34 PM by Shiva. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 09-21-2005 02:01 AM

    • mcjack
    • Not Ranked
    • Joined on 09-21-2005
    • Posts 6

    Button OnClick Event

    Hi all,

    I need to move focus to a textBox on button click event using c#.

    Thanks.

    mcjack
  • 09-21-2005 05:16 AM In reply to

    Check out this chain -http://www.infopathdev.com/forums/topic.asp?TOPIC_ID=810

    In InfoPath there is no typical focus() method to call. You have to select the correct node in the DOM.
    Jason
    http://www.k2distillery.com/
  • 09-21-2005 05:43 AM In reply to

    • mcjack
    • Not Ranked
    • Joined on 09-21-2005
    • Posts 6
    Hi,

    I've this problem: the function View.SelectText requires two parameters a node and a varViewContext which is the ID of the control that is used for the context, which is an element with the specified view context of xd:CtrlId, otherwise it gives me an error.
  • 09-21-2005 06:47 AM In reply to

    • bratt
    • Not Ranked
    • Joined on 09-21-2005
    • Posts 1
    use "Type.Missing" for the second parameter:
    VB.net:
    thisXDocument.View.SelectText(Node, Type.Missing)
  • 09-22-2005 12:37 AM In reply to

    • mcjack
    • Not Ranked
    • Joined on 09-21-2005
    • Posts 6
    Hi,

    here is my code (C#.net):
    public void CTRL81_5_OnClick(DocActionEvent e)
    {
    // Write your code here.
    IXMLDOMNode nodeAna = thisXDocument.DOM.selectSingleNode ("my:myFields/my:DatiAnagrafici/my:DatiAnagraficiLab");
    thisXDocument.View.SelectText(nodeAna, Type.Missing);
    }

    and this the error I get

    System.Runtime.InteropServices.COMException
    The specified values for the View.SelectText call are not valid.
    at Microsoft.Office.Interop.InfoPath.SemiTrust.View.SelectText(IXMLDOMNode pxnField, Object varViewContext)
    at Microsoft.Office.Interop.InfoPath.SemiTrust.ViewObjectWrapper.SelectText(IXMLDOMNode pxnField, Object varViewContext)
    at Microsoft.Office.Interop.InfoPath.SemiTrust.ViewObjectWrapper.SelectText(IXMLDOMNode pxnField, Object varViewContext)
    at InfoPathProject2.InfoPathProject2.CTRL81_5_OnClick(DocActionEvent e)
    in c:\documents and settings\u010101275\my documents\italcementi\myvisualstudioprojects\infopathproject2\infopathproject2\formcode.cs:line 38

    Can you hel me?
    Thanks
  • 09-23-2005 03:40 AM In reply to

    • mcjack
    • Not Ranked
    • Joined on 09-21-2005
    • Posts 6
    Hi all,
    I've found the problem.
    here the solution: the textbox mustn't be read only.

    Regards
  • 10-05-2005 12:56 AM In reply to

    check your xpath properly

    IXMLDOMNode nodeAna = thisXDocument.DOM.selectSingleNode ("my:myFields/my:DatiAnagrafici/my:DatiAnagraficiLab");

  • 02-21-2007 12:18 PM In reply to

    • Bill
    • Top 200 Contributor
      Male
    • Joined on 09-26-2006
    • USA
    • Posts 57
    Hello,

    I am having a similar issue when attempting to set the focus to a check box: I run this code (written in VB) in an afterUpdate event:

    Dim objectField1 = e.Xdocument.DOM.selectsingleNode("/dfs:myFields/dfs:datafields/d:AForm49B/@Gender")

    e.xDocument.View.SelectText(objField1, Type.Missing)



    and I receive this error:

    The specified values for the View.SelectText call are not valid.
    at Microsoft.Office.Interop.InfoPath.SemiTrust.View.SelectText(IXMLDOMNode pxnField, Object varViewContext)
    at Microsoft.Office.Interop.InfoPath.SemiTrust.ViewObjectWrapper.SelectText(IXMLDOMNode pxnField, Object varViewContext)
    at DHS49B.DHS49B.CTRL7_OnClick(DocActionEvent e) in E:\goldmine\GMForms\DHS49Forms\DHS49Forms\DHS49B\DHS49B\FormCode.vb:line 752
    at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)

    Can anyone tell me what I am doing wrong?

    Thanks!

    Bill
    William L Fringer
    Database Administrator/Systems Integration Specialists

    L & S Associates, Inc.
    Michigan State University Corporate Research Park

    1-800-766-6185, ext 2076
  • 02-25-2007 11:34 PM In reply to

    • Shiva
    • Top 25 Contributor
    • Joined on 04-15-2005
    • India
    • Posts 694
    Hi Bill,

    You have to check the ‘objectField1#%92 node is getting or not before set the focus. If you are getting the node then below the syntax is correct to set focus this filed. One more is the textbox should not be read only as per mcjack.
Page 1 of 1 (9 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.