Click here to Skip to main content
15,885,877 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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")
Posted
Updated 11-Aug-14 19:37pm
v3

You have tagged your question in C# and your requirement is in VB.NET, first update your question.

vb.net

VB
Dim query as Integer =Convert.ToInteger(Request.QueryString("rid"))
       if query=6 than
           //do your stuff
       else
           //do your stuff
       end


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.
 
Share this answer
 
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="/KB/answers/selectedreport.aspx"?rid=<%=request.querystring("rid")%> &name=<%=request.querystring("name")%
 
Share this answer
 
If you're using C#, the code should be:
C#
request.querystring["rid"].Equals("6");
 
Share this answer
 
v2
Comments
venky1988 11-Aug-14 21:47pm    
my code is in vb .net , can you please suggest this in vb.net
venky1988 11-Aug-14 21:50pm    
this if condition is working fine with the initial request , but when i am trying to do a input button reset_onclick to load all initial values for this , it failing in if condition
Trung Nguyen Son 11-Aug-14 21:57pm    
I think it's just your logic problem. Plz double check it!
Trung Nguyen Son 11-Aug-14 22:06pm    
The "if condition" is in the page load event, right? Or in the button click event?
venky1988 11-Aug-14 23:01pm    
the if condition is in a method which is called in page load ...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900