使用response.redirect查询字符串 [英] query string with response.redirect
问题描述
我正在使用response.redirect传递一个查询字符串,它将转到页面并检查if条件中的查询字符串值,但是如果条件返回false,即使查询字符串中存在所需的值
我的代码:
response.redirect(2.aspx?rid = 6)
另一方面if条件如下
if(request.querystring(rid)=6)
{
}
在调试的时候我把这个查询字符串用来快速观察它显示为6
但if条件失败:if(request.querystring(摆脱)=6)
i am passing a query string with response.redirect, it is going to the page and checking the query string value in if condition , but if condition is returning false even though needed value is there in query string
my code :
response.redirect("2.aspx?rid=6")
on ther other side the if condition is as below
if(request.querystring("rid")="6")
{
}
while debugging when i take this query string in to quick watch it is showing as "6 "
but the if condition is failing : if(request.querystring("rid")="6")
推荐答案
您已在C#中标记了您的问题,并且您的要求是在VB.NET中,首先更新您的问题。
vb.net
You have tagged your question in C# and your requirement is in VB.NET, first update your question.
vb.net
Dim query as Integer =Convert.ToInteger(Request.QueryString("rid"))
if query=6 than
//do your stuff
else
//do your stuff
end
< br $> b $ b
c#
c#
if (Request.QueryString.Count > 0) {
int Query = Convert.ToInt32(Request.QueryString["rid"]);
if (Query == 6)
{
//Do your stuff
}
else {
//Do your stuff
}
}
根据需要修改此代码。
Modify this code according to your need.
this在传递查询字符串值时出现问题,我在第一个查询字符串后给出了一个空格,现在删除空格后它正常工作onclick =javascript:location.href ='selectedreport.aspx?rid =<%= request.querystring( rid)%>&name =<%= request.querystring(name)%
this is a problem while passing query string values , i gave a space after 1st query string , now after removing space it is working fine onclick="javascript:location.href='selectedreport.aspx?rid=<%=request.querystring("rid")%> &name=<%=request.querystring("name")%
如果您使用的是C#,代码应为:
If you're using C#, the code should be:
request.querystring["rid"].Equals("6");
这篇关于使用response.redirect查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!