Introduction to ASP Programming (III): Contact script Program

Source: Internet
Author: User
Tags iis modify split
Programming | programs | scripting | Scripts with the previous HTML in the form of the reinforcement knowledge, is not thinking, the following can start the ASP trip? Not necessarily.
The general system has learned the ASP's programmer to be aware of: before the system learns the ASP's built-in object and the built-in component, learns the scripting language is always essential.
Why do you say that? Why do you want to learn scripting language? What's the relationship between ASP and scripting languages?

First of all, let's say ASP is what you are. ASP, the abbreviation for Microsoft Active Server Pages, is a server-side scripting environment that you can use to create interactive Web pages and build powerful Web applications. Can show that ASP is a server-based scripting environment, then understand why the ASP needs IIS support, because IIS is a common class of Web servers; That's why you learn scripting languages, because the ASP provides a scripting environment.

Again, the ASP is just an environment, not a language. If you really want to visualize that ASP is a Web programming language, it is also a powerful hybrid language for the built-in objects and components provided by a html+ script +asp.

So, learning a little script is very important! In fact, whether it's a scripting language or any other language, I think the first thing I need to know is the various features that the language covers, includes data types, events, methods, objects, attributes, syntax, and so of course, it's all empty talk, just as in a college class, a computer language class, the pure research is to feel some rope and tasteless. Or practical good, can solve the problem of the program is a good program (proof can catch mice cat is a good cat classic holy language, hehe)

Of course, the language of this thing still want you to study well, such as you write the absolute value of the program, in fact, an ABS () function is done. For example, you will be VB script, but the same program to replace the same Java script will be wrong, their data type is different, the syntax of the sentence is not the same. As in Chinese and foreign languages, the pronunciation of the mark (data type), how to pronounce (method), how to say a sentence (grammar) ... Oh, a little make you uncomfortable. Yes! Straight up. What you need to pay attention to in the future is the function and syntax of the language. Of course not to let you all look, follow the tutorial in the encounter a master. The tutorial finished, almost also finished. Oh, you have to believe me.

There are currently two main scripting languages: VBScript and JavaScript. Because VBScript is the default server script for IIS, what we're talking about is basically an ASP that is scripted around VBScript, and of course it doesn't rule out the use of JavaScript sometimes.

To give a very simple example:

<script language= "VBScript" >
<!--
Sub Button1_onclick
MsgBox ("Welcome to use vbscript!")
End Sub
-->
</script>

<script language= "JavaScript" >
<!--
function b213 ()
{
Alert ("Welcome to use javascript!")

}
-->
</script>
<form>
<input type= "button" Name= "Button1" value= "VBS" ><br>
<input type= "button" Name= "Button2" value= "JS" onclick= "b213" () >
</form>
The sub in VBScript is an event procedure. The procedure name consists of two parts: a button name, Button1 (obtained from the Name property in the < INPUT > tag), and an event name, or OnClick. The two parts are connected by an underscore (_). When you click the button, Internet Explorer looks up and runs the appropriate event procedure, that is, Button1_onclick, and MsgBox is a function, and for its more specific parameters, you look good.
[Ctrl + A ALL SELECT hint: You can modify some of the code, and then run]

On the spur of the moment, maybe everyone can see the internet a kind of crazy disgusting dialog box group, what is the principle? Please see:

<script language= "VBScript" >
MsgBox "You know you'll be a little bit sure .... "
MsgBox "No point also points ... "
MsgBox "No way Is it ...?" "
MsgBox "Otherwise the webpage can't open ah ... "
MsgBox "This is a trick ... "
MsgBox "Really want to beat the webmaster ... "
</script>
In fact, the webmaster use these to play with others, the first play with their own: because this is what he came up with AH:
Oh, I did not damage everyone's meaning, just to learn.
[Ctrl + A ALL SELECT hint: You can modify some of the code, and then run]

In the open page and page back pop-up dialog box principle
<script language= "VBScript" >
<!--
Sub Window_onload ()
MsgBox "Welcome you!"
End Sub
Sub Window_onunload ()
MsgBox "You late!"
End Sub
-->
</script>
Open page display "Welcome you!", close the page to show "See You late! ”
[Ctrl + A ALL SELECT hint: You can modify some of the code, and then run]

The above is just a display dialog box MsgBox, and of course, the Writing dialog box InputBox also by the way.

<script language= "VBScript" >
<!--
Dim strname
Strname=inputbox ("Enter your name please:", "Enter your name", "Cnbruce")
document.write (strname& ", welcome you!<p>")
-->
</script>
About the InputBox of the parameters also go to see it.
[Ctrl + A ALL SELECT hint: You can modify some of the code, and then run]

Let's look at a few more useful functions:
Len (): Returns the length of a string or the byte length of a variable
LEF (): Intercepts the contents of the first part of a string
Right (): intercepts the latter part of a string
<script language=vbs>
text= "1234567890ABCDEFGH"
i=10

Lentext=len (text)
Lefttext=left (Text,i)
Righttext=right (Text,i)

Alert ("Text length is:" &lentext)
Alert ("Text left &i&" is: "&lefttext)
Alert ("Text right Takes &i&" is: "&righttext)
</script>
[Ctrl + A ALL SELECT hint: You can modify some of the code, and then run]

According to these few, often see the long article after the "..." situation is as follows:

<script language=vbs>
text= "123 4567 8fds90 ABCDE FGHXCFV"
i=10
If Len (text) >i Then ' if the text length is greater than the given value
Text=left (text,i) ' Extracts the string of the I-bit of the preceding paragraph
Alert (text& "...")
Else
Alert (text)
End If
</script>
[Ctrl + A ALL SELECT hint: You can modify some of the code, and then run]

There is also a more important function of replace ()
Finds in a string, substituting the specified string
Replace (Strtobesearched,strsearchfor,strreplacewith)
Strtobesearched is a string; strSearchFor is the substring being looked for; strReplaceWith is the substring to be substituted.
One of the following is a very useful text-to-speech program.
<script language=vbs>
text=, "Damn it, I'll do it."

Text=replace (text, "Ma", "MD")
Text=replace (text, "Exercise", "Cao")
Alert (text)

</script>
[Ctrl + A ALL SELECT hint: You can modify some of the code, and then run]

Often in sending emails, add multiple addresses, the middle of the ";" to separate, that specific how to decompose a number of e-mail addresses received over it? Using the Split function: The Split function returns an array from the string.
<script language=vbs>
Cnbruce= "Cnbruce@126.com;cnbruce@it365cn.com;root@cnbruce.com"



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.