ASP JavaScript Tutorial - Lesson 03 The New String () Constructor

xiaoxiao2021-04-09  450

The New String () Constructor

Get Started:

NEW STRING () IS Another Strange Place To Go Early on The Lesson Plan. But Just Like Escape Characters, New String () IS Vital To Successful ASP JavaScript Applications. Below Are Two Scripts for Lesson 03.

<% @ Language = "javascript"%>

<%

// no asp here, Just a regular html page

%>

Type Something Into the text box and subsiT.


How much Money Do you make each month?

Click Here to Run The Script in a New window.

Below is The Actual ASP Script That Does The Heavy Lifting.

<% @ Language = "javascript"%>

<%

Var webpagevariable = new string (Request.form ("WebPageVariable"))

WebPagevariable = WebPageVariable.touppercase ();

Var monthlysalary = new string (Request.form ("MonthlySalary)))

MonthlySalary = monthlysalary.tolowercase ();

Response.write (" / R");

Response.write ("The Web Page Variable You Typed IS:");

Response.write (WebPageVariable "
/ R");

Response.write ("THE MONTHLY SALARY You Listed IS:" MONTHLYSAlary "
/ R");

Response.write (" / r");%>

NEW STRING () in Action:

Now Check Out The Asp Lines Below.

Var monthlysalary = new string (Request.form ("MonthlySalary)))

MonthlySalary = monthlysalary.tolowercase ();

Request.Form gets its own lesson later on. Here's the point of showing it to you now. The data held in Request.Form (which ultimately comes from the user) is not a JavaScript data type. Instead, it is a native ASP data JavaScript Cannot Manipulate ASP Data Types.

...........................

Quick Note:

IFORM back out to the user NEED new string ().

WITHOUT New String ():

Take a look at the line i printed below.

Var WebPagevariable = Request.form ("WebPageVaraible"). TouPpercase ();

Error! The Line Above Will throw An Error Because

Request.form ("WebPageVaraible")

IS an ASP Object, And

TouPpercase ()

IS A JavaScript Method.

Microsoft Jscript Runtime Error '800A01B6'

Object Doesn't Support this Property Or Method

/ASP/SECTION01/Script03b.asp, Line 9

Moving forward:

Now That We Have Escape Characters and new string (), Everything else We Want to do in ASP JavaScript Becomes a Lot Easier.

You is not seen nothing yet. We can mix and match JavaScript functions and methods with VBScript functions and methods. VBScript and JavaScript functions can pass arguments back and forth. They work wonderfully together. That will be the subject of lesson 04.

转载请注明原文地址:https://www.9cbs.com/read-133071.html

New Post(0)