This document will give you an in-depth idea on how to embed a Web page within an InfoPath form. The Web page can be invoked with different URLs on click of a button.
The proposed solution below will help us avoid using Activex controls to act as custom controls within an InfoPath form. This will also avoid the problems of having a
webBrowser control within an Internet browser page (see this article).
It is nearly impossible to add an iframe to the
Xdocument.DOM of InfoPath.
An application form has to get details from a given URL in the InfoPath page. The user will click on the URL and the Web page will be populated within the InfoPath form, so that the user doesn't have to navigate out or switch to a different browser window.
A new TaskPane will be created and associated with the InfoPath form. This TaskPane by default will take a simple user created HTML page. On click of the button to the right of the given URL, TaskPane will be navigated to that specific URL. This is done by invoking an onclick event which navigates the TaskPane to the given URL.
Step By Step Walk-through
Open Notepad and paste the following:
Click on the Go button against the URL to open the web page
- Save and close the Notepad file as myTaskPane.HTML
- Open a new form in the Design Mode in InfoPath
- Go to Menu/Tools/Form options/Advanced
- Check “Enable Custom Task Pane”
- Type Task Pane name as
- Click on the Resource Files and add myTaskPane.HTML from its location
- Select Task Pane location as myTaskPane.HTML from the Form Option window
- Click Ok to close the Form Options window
- Add the textbox named
URL to the form
- Add a button on the right of the URL textbox with a name/ID
btnGo; label the button as
- Double-click on the GO button
- Click “Edit Form Code” button
A script editor will be opened; paste the below code in the editor, save and close.
objXMLNode = XDocument.DOM.selectSingleNode("/mySample/URL");
if (objXMLNode.text != "" && objXMLNode.text != null)
objTaskPane = XDocument.View.Window.TaskPanes(0);
- Click on the Preview Form, type a URL and click GO... works!!
- Close the preview and save the form.
Note: If you would like to publish this form to public, you need to remove the security restrictions.
- Go to Menu/Tool/Forms Options/Security
- Uncheck “automatically determine security..”
- Check Full Trust option
- Check ‘Sign this form” and create or use a certificate
Install this certificate in the client computer where you use this form.
This is a simple solution for having a Web page within an infoPath form. Task Pane can be moved to any corner of the infopath window as per user’s convenience. Security levels of the forms have to be decided as per the requirements.
For any further information or any queries, reach out to me at firstname.lastname@example.org
My blog: www.firozozman.com.
- 5th October, 2006: Initial post