什么是的Request.QueryString(),以及如何来检查它是否是空的类型? [英] What is the type of Request.QueryString() and how to check if it's empty?

查看:338
本文介绍了什么是的Request.QueryString(),以及如何来检查它是否是空的类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许是微不足道的问题,但我不知道是什么的Request.QueryString的类型()。当我用typeof检查它 - 它说,它的对象。如何检查哪些对象是和该对象的属性是URL字符串?

Maybe it's trivial question, but I have no idea what is the type of Request.QueryString(). When I check it with typeof - it says it's Object. How to check which object it is and which property of that object is a string in URL?

我与语言的规范做服务器端<%@ LANGUAGE =JavaScript的%>

I'm doing it server side with language specification <%@ language="javascript"%>

如果我有这样的网址:
http://127.0.0.1/Kamil/Default.asp?name=
那么如何检查,如果名称为空?这不是空。我知道我可以转换的Request.QueryString(名称)来串并检查它是否是空字符串,但它是正确的方法是什么?

If I've got URL like that: http://127.0.0.1/Kamil/Default.asp?name= then how to check if name is empty? It's not null. I know I can convert Request.QueryString("name") to String and check if it's empty string "", but is it proper way?

推荐答案

请求收集是继承的 IRequestDictionary 接口。

在JScript中,它的使用项目获得实际的价值,而不是隐含其中之一为的查询字符串 collection(也的表单 ServerVariables )是 IStringList 其实。

你说你知道C#这样你就会明白以下虚构查询字符串的声明。

The Request collection is an object that inherits IRequestDictionary interface.
In JScript, it's a good practice to use item to get actual value, not the implicit one due to values of the QueryString collection (also Form and ServerVariables) are IStringList in fact.
You said you know C# so you'll understand the following fictitious QueryString declaration.

var QueryString = new IRequestDictionary<string, IStringList>();

和几个例子,你应该如何检查在JScript中的值,而不串转换。

And a few examples how you should check the values in JScript without string conversion.

if(Request.QueryString("name").count==0){
    // parameter does not exist
}

if(Request.QueryString("name").item==undefined){
    // parameter does not exist
}

if(Request.QueryString("name").item!=undefined){
    // parameter exists and may be empty
}

if(Request.QueryString("name").item){
    // parameter exists and non-empty
}

这篇关于什么是的Request.QueryString(),以及如何来检查它是否是空的类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆