March 2006 - Posts - Shanthi Reddy
in

InfoPath Dev

Shanthi Reddy

March 2006 - Posts

  • Create Custom Task Pane for Password

    Password fields cannot be created in the InfoPath forms. Therefore, the password fields should be set in the custom task pane.

    In this task, we will create a custom task pane HTML file in a text editor and add it to an InfoPath form. We will add a Submit button and also put a function on this button to switch views in the InfoPath Form. After getting the password into a password variable, access database to validate your password.

    Copy the following code into a text editor and save the file as Password.html.

    <html>
        <head>
            <script language="javascript">
                var thisXDocument = null;
                function initialize()
                {       
                    thisXDocument = window.external.Window.XDocument;
                }
                function changeView()
                {   
                    var userName = tbUser.value;                   
                    var password = tbPassword.value;               
                    /*Access your database to find out if the logged in user is a valid user or not.*/       
                    thisXDocument.View.SwitchView("Main Form");
                }
            </script>
        </head>
        <body onload="initialize()">
            <table>
                <tr>
                    <td>
                        Username:
                    </td>
                    <td>
                        <input type="text" name="tbUser" id="tbUser" size="15">
                    </td>
                </tr>
                <tr>
                    <td>
                        Password:
                    </td>
                    <td>
                        <input type="password" name="tbPassword" id="tbPassword" size="16">
                    </td>
                <tr>
                    <td></td>
                    <td>
                        <input type="submit" value="Submit" onclick="changeView();">
                    </td>
                </tr>
            </table>
        </body>
    </html>

    Add the HTML file as the Resource file:

    1. Open InfoPath, click Design A Form, select New Blank Form in the Design A Form task pane.
    2. Choose Form Options from the Tools menu.
    3. Switch to the Advanced Tab, select Enable Custom Task Pane check box, and then click Resource Files.
    4. Click Add, locate the Password.html file that was created above, and then click OK.
    5. Name the task pane Password (as shown in Figure 1), and then click OK to close the Form Options dialog box.


    Figure 1. Adding the Custom Password Task Pane.

    1. Create a second View and name it as Main Form.
    2. Click on the View Properties in the task pane to open View Properties window.
    3. Uncheck the check box Show On The View Menu When Filling Out The Form under General tab.


    Figure 2. Add a second view, Main Form in the Views Task pane.

    1. Preview the form and enter the Username and password in the task pane, as shown in Figure 3.
    2. Click on the submit button, The form shifts into second view, Main Form.


    Figure 3. The Completed Task Pane applied to the InfoPath Form.


    Figure 4. The form switches to the second view when submit button is clicked.

Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.