Choosing a Scripting Language

See Also

Microsoft® Visual InterDev™ allows you to design Web applications using the scripting language you are most comfortable with. Your application can contain a mix of files that use VBScript and JScript™. You can even use different languages on the same page, but the script inside a single script block must contain a single scripting language.

To set the scripting language for script block

If you do not set a language for a script block, a default is assumed. The default for server script run by Microsoft® Internet Information Server (IIS) is established as a server setting (usually VBScript). For client script, the default language is determined by the browser. Most browsers use JavaScript as their default language. Microsoft® Internet Explorer assumes JavaScript as its default language, but will reset the default language for the current page to the first LANGUAGE attribute it encounters in a <SCRIPT> block. (It does not reset the default again after the first LANGUAGE attribute.)

Choosing a Language for ASP Files

Because ASP pages can contain inline script that is not in a <SCRIPT> block, they provide a means for resetting the default for the page as a whole. At the top of each ASP page, a <%@ LANGUAGE= %> directive specifies the default scripting language. You can change this setting manually or by setting a property value.

To change the scripting language for an ASP file

  1. With nothing selected in the editor, choose Property Pages from the View menu.

  2. In the Property Pages dialog box, choose the General tab, and then under Default scripting language, choose the language in the Server list.

Design-time controls also use the LANGUAGE directive to know what language they should use to generate script. If you delete the <%@ LANGUAGE= %> directive in a file, the Visual InterDev controls generate script using the language currently specified in the Properties dialog box for the page. In addition, when these pages are run on the Web server, they will be processed using the language set in the DefaultScriptLanguage parameter under the ASP entry in the Web server registry.

Note   If you have pages without the <% @ LANGUAGE= %> directive, make sure your language setting in the Options dialog box is identical to the default language set on your server; otherwise, the controls will generate code in the wrong language.

You can set the default for all new ASP pages you create.

To reset the default scripting language for new ASP pages

  1. Right-click a project in the Project Explorer, and then choose Properties.

  2. In the Property Pages dialog box, choose the Editor Defaults tab.

  3. Under Default script language, select the language you want in the Server list.

If you change the default scripting language, new files you create will reflect the change, but the specified scripting language in your existing files will not change.

Choosing a Language for the Global.asa file

When you create a new project, the default script language you specify in the Options dialog box is used to define the events in the Global.asa file. You can change the language used for those events.

To change the script language for the Global.asa file

  1. In the editor, open the Global.asa file.

  2. In each script block, change the LANGUAGE attribute.

Choosing a Language for Generated Scripts

If you write scripts by hand, you can set the scripting language yourself using the procedures above. However, you can also set a default scripting language for script that you generate using the Script Outline window.

To change the scripting language for generated scripts

  1. With nothing selected in the editor, choose Property Pages from the View menu.

  2. In the Property Pages dialog box, choose the General tab.

  3. Under Default scripting language, choose the default language for client and server scripts.

Note   This change affects only new scripts, not existing ones.

You can also change the default language for script generation for your project as a whole.

To reset the default scripting language for new ASP pages

  1. Right-click a project in the Project Explorer, and then choose Properties.

  2. In the Property Pages dialog box, choose the Editor Defaults tab.

  3. Under Default script language, select the default language for client and server scripts.

Note   This change affects only new pages, not existing ones.