11.2. Choose Your Flavor of Code: Script or Managed Code (.NET)

Version 1.0 of Microsoft InfoPath originally shipped with Microsoft Script Editing technologies, giving the user the choice of using either Microsoft JScript, which is the default scripting language for a form, or Microsoft Visual Basic Scripting Edition (VBScript). Other Microsoft Office products ship with Visual Basic for Applications (VBA), except for Outlook, which also uses scripting to program with Outlook forms.

11.2.1. JScript or VBScript?

The choice of which of the scripting languages you depend on may come down to which one you have had experience with. If you have used Java in the past, you may want to use Jscript; if you have used one of the Visual Basic development languages, then VBScript may be the way to go.

If you're just starting out in developing, you will probably want to use the default scripting language, which is JScript. If you decide to go with VBScript, then you change the default script language by selecting it on the Advanced tab of the Form Options dialog box.

If you want to change the default programming language behind an InfoPath form, you have to do it before the form has any code behind it.

11.2.1.1. Try It Out: Setting the Default Script Editor

Using a new form:

  1. Open InfoPath.

  2. Create a new blank form.

  3. Choose ToolsForm Options.

  4. Click the Advanced Tab.

  5. Click on the Form code language, under the Programming Language section. The drop-down list can be seen in Figure 11-1.

    Figure 11.1. Figure 11-1
  6. Select the language of your choice.

  7. Click OK.

The language will now be specified, and InfoPath and Microsoft Script Editor will create the necessary commands in a script file.

11.2.2. Managed Code with .NET

With the introduction of InfoPath 2003 Toolkit for Visual Studio .NET, developers have other choices when deciding what programming language to use behind their InfoPath forms. Developers can use managed code in .NET to write code for their forms. .NET managed code languages, such as C# and Visual Basic .NET, are supported for InfoPath.

Besides simply allowing you to create managed code files behind your InfoPath forms, Microsoft also provides support in Visual Studio .NET for InfoPath project files, giving you a development platform in which to create your applications. Assemblies and classes are provided for working with the InfoPath object model, providing access to methods, properties, and events. Events and the InfoPath object model are discussed in the remaining sections of this chapter.

While .NET and creating InfoPath applications in .NET will be covered in detail in Chapter 13, "Working with .NET Managed Code," the first thing you want to do is download and install the InfoPath 2003 Toolkit for Visual Studio .NET.

If you want to use the toolkit mentioned earlier, then you will already need to have Visual Studio .NET installed with the desired language: C# or Visual Basic .NET.

11.2.2.1. Try It Out: Downloading the InfoPath 2003 Toolkit for Visual Studio .NET

On your development machine that you are using to create your InfoPath forms:

Microsoft may have changed some of the links and Web pages by the time you read this. But you should be able to find the download using these pages.

  1. Using your favorite Internet browser, go to the Microsoft Office Online Web site. As of this writing the Web address was:

    http://office.microsoft.com/en-us/officeupdate/default.aspx

    You can see the page shown in Figure 11-2.

  2. Click Downloads for Office 2003, located under BROWSE DOWNLOADS in the middle of the page. The Downloads for Office 2003 page will be opened.

  3. Click the Add-Ins link under InfoPath 2003. The Add-Ins for InfoPath 2003 page will be displayed, listing the InfoPath 2003 Toolkit for Visual Studio .NET.

  4. Click the InfoPath 2003 Toolkit for Visual Studio .NET link. The download page will then be displayed.

  5. Click Download. If you are in Internet Explorer, a security warning is given.

  6. Click Run to download and install the toolkit. You will see the message displayed in Figure 11-3.

    Figure 11.2. Figure 11-2

    Figure 11.3. Figure 11-3

After downloading and installing the toolkit, you can open Visual Studio .NET. When you select a new project, additional choices will be displayed, offering C# or Visual Basic .NET projects, as shown in Figure 11-4.

Figure 11.4. Figure 11-4

Creating a project using managed code will be covered further in Chapter 13. For now, take a look at what it means to develop using event-driven programming.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.65.208