ASP Objects Object

Source: Internet
Author: User

ASP objects
An object is a kind of encapsulation of multiple methods (just like their functions) and variables in an easily managed Uber variable (object). The ASP object is similar to other object-oriented programming languages. In this lesson, we will use the ASP CDO. The message object is dissected as our example object.

ASP objects
Objects are built to deal with increasingly complex programming. Reason to understand and use object programming in is making programming easier and more people reading your code.

ASP technology creates an object-S erver. CreateObject
An object in ASP is created by creating a Server.CreateObject function of a name string (actually called a method). The string creates a mail object that is "CDO." Message ". We will create a Cdo.message object in this example.

Note: Because objects are special in existence is a special way to create and destroy keywords that they use to set. These areas are marked in red in the following example.

<%
Dim MyObject
Set myObject = Server.CreateObject ("CDO.") Message ")

' Must Set your objects to ' nothing '
' The computer memory that is allocated to it
Set myObject = Nothing
%>

It's not too painful, what is it? Let's make some more basic object models.

The object is a collection of related things that are combined with the program story that can be created and destroyed when we may need it. For example, say you want an object that allows you to send email ...

So there are some things that all emails: to, from the CC, the subject etc This list of variables, is common to each email will be very annoying to create for each email we send out. Wouldn't that be nice if we could build some sort of Uber variable (object) to incorporate all these smaller variables into one thing?

Object properties for ASP
These smaller variables are often referred to as an object's properties and formatting these properties are almost the same setting a variable equals a value.

The correct syntax for setting an object's properties is:

Objectname.propertyname = Somevalue
In this small example below we are creating a new mail object and determining its want and from attributes.

<%
Dim MyObject
Set myObject = Server.CreateObject ("CDO.") Message ")

' Then we set the to and from properties
myobject.to = "little.timmy@example.com"
Myobject.from = "Huge.jill@example.com"

' Must Set your objects to ' nothing '
' The computer memory that is allocated to it
Set MyObject = Nothing
%>

Now I know that we haven't done anything in the above example, but we still need to learn some more objects and then we can get anything! objects, in addition to having a cluster-related common variable, may also collect functions (become known as methods) associated with them.

These method procedures that you want to do usually manipulate the object of the variable or the variables used to do something. In our Message object we have a collection of information that when sorted into the proper form and email sent to an email service will become an email.

All this complex code has been programmed by Microsoft employees and stored information to send objects to the method.

Methods for ternary composite objects
We can't see the way code is used to deliver programs, but it's a great thing to use object programming. You know you need to know, that's all. In our example below we create a Message object and set the necessary property and turn it off by the Send method.

<%
Dim myObject
Set myObject = Server.CreateObject ("CDO. Message "]

' Then we set the to and from properties
Myobject.to =" little.timmy@example.com "
Myobject.from = "huge.jill@example.com"
myobject.subject = "Can you click me?"
Myobject.textbody = "I ' m really really big!"

Myobject.send ()

' You must Set your objects to ' no ' to ' the ' ' ' the ' ' The
' computer memory That is allocated to it
Set myObject = Nothing
%>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.