Updating content of Text Box at runtime - InfoPath Dev
in

InfoPath Dev

Updating content of Text Box at runtime

Last post 06-21-2012 10:47 AM by brjames. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 06-20-2012 04:49 AM

    • brjames
    • Not Ranked
      Male
    • Joined on 06-20-2012
    • Tenby, Wales
    • Posts 2

    Updating content of Text Box at runtime

    Hi all

    I'm trying to do something which due to my extensive background in VB.net programing should be simple but isn't!! All I'm trying to do is update the contents of a text box at run time with a Users' username. The code I'm using to test the text box updating is:

    Public Sub FormEvents_Loading(ByVal sender As Object, ByVal e As LoadingEventArgs)

    ' Write your code here.

    Dim root As XPathNavigator = MainDataSource.CreateNavigator()

    Dim textbox As XPathNavigator = root.SelectSingleNode("/my:myFields/my:myIP", NamespaceManager)

    textbox.SetValue("

    test")

    End Sub

    When I run it, nothing gets putinto the text box so it remains blank.

    Can anyone see where I'm going wrong? Oh yeah - I'm using Infopath 2010 to create a Web Browser Form but it's saved as 2007 version.

    Thanks in advance

  • 06-21-2012 10:14 AM In reply to

    Re: Updating content of Text Box at runtime

    Have you considered using the xpath function userName()?  You can set the value of the text box via rules or default value and this wouldn't require writing any custom code.
    Anson Hidajat
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™

  • 06-21-2012 10:47 AM In reply to

    • brjames
    • Not Ranked
      Male
    • Joined on 06-20-2012
    • Tenby, Wales
    • Posts 2

    Re: Updating content of Text Box at runtime

    Anson Hidajat:
    Have you considered using the xpath function userName()?  You can set the value of the text box via rules or default value and this wouldn't require writing any custom code.

    Yes I've found this out now thanks. What I also wanted to use the above code for is to populate a textbox with the users IP Address. Any ideas how I can do this?

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