Access control properties with script - InfoPath Dev
in

InfoPath Dev

Access control properties with script

Last post 04-03-2009 10:21 AM by christian_bahnsen. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 03-22-2009 01:37 PM

    Access control properties with script

    Hi,
    I've created some custom control using C#, i want on form load, via JScript, to pass some data to my control.
    However, i can not access any of my control propeties using the script:

    var usersControl = XDocument.DOM.selectSingleNode("//my:field1");
    usersControl.Value = "456";
    or
    usersControl.displayField = "33";

    Altought those properties are com visible:
    [ComVisible(true), Browsable(true)]
    public string displayField...

    It seems like the DOM.selectSingleNode returns the control's data from the form's XML and not the control instance itself.

    How can I interact with my custom control using script in the form? My main goal is to pass data from web service to my contro.

    Thanks.

  • 03-22-2009 07:30 PM In reply to

    Re: Access control properties with script

    As you have surmised, selectSingleNode() returns a reference to an XML node, not a control.  There isn't really any way to directly interact with an InfoPath control from within the form's code.

    To set the value of a node object (usersControl in the code you pasted), you can set the text property.

    usersControl.text = "456";

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 04-01-2009 02:14 PM In reply to

    Re: Access control properties with script

    I hope you're kidding when you say "There isn't really any way to directly interact with an InfoPath control from within the form's code."

    I'm new to InfoPath but an old-timer building applications in Office with VBA.  I've learned that InfoPath doesn't support VBA; OK, I can live with that.  But if I can't set properties for controls programmatically or even get a control's value then I've got a problem and maybe InfoPath isn't as useful a tool as it appeared.

  • 04-01-2009 06:33 PM In reply to

    Re: Access control properties with script

    I assure you I would not kid in a forum such as this.

    As I said, there is no way to directly interact with a control from the code.  An InfoPath form is a visual representation of an XML document, and you can indirectly interact with controls (get and set values, add and delete rows from repeating sections) by interacting with the form's XML.  Some changes to form controls' visual properties can be accomplished through the use of conditional formatting in a form template's settings.

    I and many others on this forum have found InfoPath to be quite a handy and versatile tool.  I recommend having a poke around this forum to see examples of its uses and capabilities.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 04-03-2009 10:21 AM In reply to

    Re: Access control properties with script

    I agree that there are scenarios where InfoPath appears to be a good tool for a specific job and I'm sorry if the tone of my last post was strident.  As a long-time VBA developer I find it frustrating not to have access to familiar tools/methods/properties/events.  My frustration level was high when I wrote the post.  Since then I've been experimenting, trying to accomplish my goals using vbscript and jscript, and am getting close.  Thank heaven for Google and forums like this.  I find pearls of knowledge hither and yon.

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