Browse to add link to textbox - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Browse to add link to textbox

Last post 12-14-2006 07:46 AM by Matt Faus. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 12-05-2006 07:52 PM

    Browse to add link to textbox

    I want to be able to have three text boxes each with a button that allows for browsing to a file (picture file in this instance) that adds a unc link to the text box. I have the form connecting to a db and run a SQL report that I want to be able to display picture links (screen shots) easily. Any help is appreciated. Thanks
  • 12-06-2006 04:55 AM In reply to

    Re: Browse to add link to textbox

    Hi metnovas,

    put this code in your button event (note: C#)


    IXMLDOMNode nodePicture = thisXDocument.DOM.selectSingleNode("my:myFields/my:PicturePath");
    //create new OpenFileDialog object
    OpenFileDialog ofdlg = new OpenFileDialog();
    ofdlg.Title = "File Browser" ; //sets the file dialog box title
    ofdlg.InitialDirectory = @"c:\" ; //sets the initial directory displayed by the file dialog box
    ofdlg.Filter = "All files (*.*)|*.*|All files (*.*)|*.*" ; //sets the current file name filter string
    ofdlg.FilterIndex = 2 ; //sets the index of the filter currently selected in the file dialog box
    ofdlg.RestoreDirectory = true ; //restore current directory before closing
    if(ofdlg.ShowDialog() == DialogResult.OK)
    {
    //write FileName/Path into the textbox
    nodePicture.text = ofdlg.FileName ;
    }
    Listen to Motörhead cos they play Rock'n Roll :)
  • 12-06-2006 07:44 AM In reply to

    Re: Browse to add link to textbox

    I'm a newbie so I'm guessing that I set this to rules and code for the action and then form code (which seems to want jscript) but how do I get it to post the link to the textbox next to the submit button? Also, is it possible to just use the attach file control and have that submit the file to a database or is that not allowed? Thanks
  • 12-07-2006 07:54 AM In reply to

    Re: Browse to add link to textbox

    Hi metnovas,

    The code nukkumatti provided is C# and I believe managed code is the only way to achieve exactly what you are trying to do. For this you will need Visual Studio 2003 or 2005 along with the Visual Studio tools for Office installed. It would also be a good idea to install the InfoPath SDK if you haven't already.

    However, your second idea about simply using a file attachment control might work, but you will want to watch out for the extra bytes InfoPath adds to the byte stream whenever you attach it to the form.

    Hope this helps and good luck!
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 12-07-2006 09:21 AM In reply to

    Re: Browse to add link to textbox

    So I'm guessing that I'd have to build the form from scratch in VS or is there a way to cleanly import it?
  • 12-14-2006 07:46 AM In reply to

    Re: Browse to add link to textbox

    You can import the template whenever you create a new project in Visual Studio. This will disconnect any JScript code you may have written from the form, but the script.js file should still be there for reference.
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.