Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with query string!!

Status
Not open for further replies.

shaminoo

Programmer
Aug 28, 2006
7
US
I have a1.aspx that has 3 hyperlinks [Reports,compass,training] ,that go to same page a2.aspx.
on a2.aspx there is a "OK" button,and on button click,different hypelink on a1.aspx should take to different pages.
I have used querystring "url?=" on href of hyperlinks

The href for hyperlinks used on a1 is--
Reports: a2.aspx?url=compass: a2.aspx?url=training: a2.aspx?url=
The snippet for the code on a2.aspx is---

protected void Button1_Click(object sender, EventArgs e)
{
string temp1=Request.QueryString["url"];
if (temp1 == "abc.com")
{
Response.Redirect("abc.com");
}
else if (temp1 == " {
Response.Redirect(" }
else if (temp1 == "xyz.com")
{
Response.Redirect("xyz.com");
}

}

When i click on "OK" in a2.aspx it does not take me to a different page.I guess something is wrong with the loop.

Please help...i m not able to find where am i going wrong.
 
For a start try comparing the temp1 variable to the values which are possible in the querystring.
Code:
 if (temp1 == "[URL unfurl="true"]www.abc.com")[/URL]
        {
            Response.Redirect("[URL unfurl="true"]http://www.abc.com");[/URL]
        }
        else if (temp1 == "[URL unfurl="true"]www.google.com")[/URL]
        {
            Response.Redirect("[URL unfurl="true"]http://www.google.com");[/URL]
        }
        else if (temp1 == "[URL unfurl="true"]www.xyz.com")[/URL]
        {
            Response.Redirect("[URL unfurl="true"]http://www.xyz.com");[/URL]
        }
 
Hi,
Thank you for the reply...bt i m sorry , i cd nt figure out wat u meant by ths..n the code written by you seems similar to what i wrote.
Could you be more precise?
I would appriciate that.
 
1) you probably want to use a switch statement here.
2) what value does temp actually have? Is it loading the query string correctly?


Brian Begy
BugSentry - Automatic error reporting
 
why are you even checking that value? cant u just redirect off of whats there if its there?

Code:
protected void Button1_Click(object sender, EventArgs e)
{
  if (!(Request.QueryString["url"]==null))
  {
     Response.Redirect(Request.QueryString["url"].ToString());
  }
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top