redirect not working

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

heya,
i have an asp:dropdownlist with options and a button. i have some code that
should redirect the page accoding to a particular option. as my site is a
work in progress only one option should do something. my code is:

protected void GoButton_Click(object sender, EventArgs e)
{
if (LinksASPDropDownList.Visible == true)
{
if (LinksASPDropDownList.SelectedValue == " Acrobranche")
{
Page.Response.Redirect("http://www.acrobranche.com/fra/index.html", true);
}
}
}

the reason why it must be visible is because there are some other dropdown
lists with pother functions that use the same button. anyway, it wont
redirect. the page just refreshes...
can i have any advice on this matter? thanks!
 
* mensuur wrote, On 10-7-2006 19:17:
heya,
i have an asp:dropdownlist with options and a button. i have some code that
should redirect the page accoding to a particular option. as my site is a
work in progress only one option should do something. my code is:

protected void GoButton_Click(object sender, EventArgs e)
{
if (LinksASPDropDownList.Visible == true)
{
if (LinksASPDropDownList.SelectedValue == " Acrobranche")

try removing the space from your test:

if (LinksASPDropDownList.SelectedValue == "Acrobranche")

Jesse
 
Dear jesse,
i need the space. it is supposed to look like a branch as if it were a
treeview control in dropdownlist format!
 
Mensuur,
I know this may seem pedantic, but the very first thing I would do here is
set a breakpoint on the line:

if (LinksASPDropDownList.Visible == true)

and begin F11 stepping over each line to see if they are even executed.

--Peter
 
* mensuur wrote, On 10-7-2006 20:52:
Dear jesse,
i need the space. it is supposed to look like a branch as if it were a
treeview control in dropdownlist format!

I understand, but my guess is that the space is trimmed in the postback.
So if you compare against this string, it's not matching. So

1. Put the space in the dropdown as you have right now
2. Change your if statement and remove the space from there
3. Recompile and try again :)

Jesse
 
dear jesse and peter,
i have figured out what the problem was. to get the SelectedValue property
you must set the Value property on each of listitems!! i thought it meant the
text that was selected. this changes everything as the value isnt what is
displayed so i can get rid of the space....
now it works! thanks anyway guys!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top