In the past, the use of JavaScript to write ASP encountered several problems. __java

Source: Internet
Author: User
Tags script tag

1. Can I use both VBScript and JScript to write server-side scripts in one page?
How do you write it if you can?

Because the <% @language = ""%> This statement can only occur once in one page,
So want to use it to set a variety of scripts at the same time on the server side of the implementation of a page can not be done,
But you can achieve the purpose by <script language= "" runat=server> this statement.
For example, the page has this statement <% @LANGUAGE = "JAVASCRIPT" codepage= "936"%>
All scripts in <%......%> on this page must be JavaScript scripts.
Then you can use <script language= "VBScript" runat=server>......</script>
In this way, you can use the VBScript script in the script tag.
I don't know if I'm right, I'm longing for guidance.

2.ASP gets the data submitted by the client and uses JavaScript to determine whether the client has passed a parameter.

Suppose there is a page show.asp, the user may directly request the page without any parameters, but also with parameters,
show.asp?id=** like this.
Now I want to determine on the server side that there is no ID for this parameter, use JScript not to use VBScript.
I have used the following methods are not valid
if (Request.QueryString ("ID") = "") Whether or not there is a parameter ID the judgment is always false
if (Request.QueryString ("ID") = = NULL) is always False

if (typeof (Request.QueryString ("ID")) = = undefined)
if (typeof request.querystring ("ID") = = "undefined")
The above two judgements are also always false, typeof (Request.QueryString ("ID") result is Object
var id = request.querystring ("id"), or if there is no ID parameter in the URL,
The statement assigned to the ID will be an object with no content, and output undefined directly when the character prints it.
So to determine if there is no pass parameter ID, you can do a data type conversion,
var id = "" + request.querystring ("id");
OR: var id = new String (Request.QueryString ("id"));
Then it can be judged, if (id = = "undefined")
If the URL does not pass the ID this parameter, the above judgment will be true, otherwise it is false.



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.