Using Components and Objects in ASP

Using Built-in ASP objects

ASP also provides built-in objects for performing useful tasks that simplify Web development. For example, you can use the Request object to easily access information associated with an HTTP request, such as user input coming from HTML forms or cookies. Unlike using the objects provided by a COM component, you do not need to create an instance of an ASP built-in object to use it in your scripts. These objects are automatically created for you when the ASP request starts processing. You access the methods and properties of a built-in object in the same way in which you access the methods and properties of a component's objects, as described in this topic.

Calling an Object Method A method is an action you can perform on an object or with an object. The syntax for calling a method is:

Object.Method parameters

The parameters vary depending on the method. For example, you can use the Write method of the Response built-in object to send information to the browser as shown in the following statement:

<% Response.Write "Hello World" %>

Note Some scripting languages do not support the Object.Method syntax. If your language does not, you must add an entry to the registry in order to use that language as your primary scripting language. See Working with Scripting Languages for more information.

Setting an Object Property

A property is an attribute that describes the object. Properties define object characteristics, such as the type of the object, or describe the state of an object, such as enabled or disabled. The syntax is: Object.Property You can sometimes read and set the value of a property. In addition, for some objects, you can also add new properties. For example, the Ad Rotator component has a property, Border, which specifies whether the ad has a border around it and determines the border thickness.

The following expression specifies no border:

<% MyAds.Border = 0 %>

For some properties, you can display the current value by using the ASP output directive. For example, the following statement returns TRUE if the browser is still connected to the server:

<%= Response.IsClientConnected %>

You might also like...

Comments

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“It works on my machine.” - Anonymous