OKAY NOW I AM PIST! ListBox x 2. and Response.Redirect

  • Thread starter Thread starter ODB
  • Start date Start date
O

ODB

I have to Listbox's one I selected the contents of the other and i the
other i Response.Redirect to a different site, but when i hit back from the
site, my listbox is not valid, right before i redirect i clearselection on
listbox2 but the selection is still there when i return from the other site
, her is some code, please help!!!!

private void ListBox1_SelectedIndexChanged(object sender, System.EventArgs
e)
{
string tStr;
tStr = ListBox1.SelectedValue;
ListBox2.Items.Clear();
MyLinker.GetWebLinks(ref ListBox2, @"\\tim\RC Heli", tStr);
}

private void ListBox2_SelectedIndexChanged(object sender, System.EventArgs
e)
{
string tStr = this.ListBox2.SelectedValue.ToString();
ListBox2.ClearSelection();
Response.Redirect(tStr);
}


The Problem is when change the selection in the first listbox the ListBox2
_SelectedIndexChanged if fired and it redirect to a new page, where it
should have change the contents of listbox2, i guess it is because the
change of the listbox2 contents fires the selected event, but how do i
remove the selected item in the listbox when the user hits back from a
different site ???


ODB
 
I have funde the solution for my problem, it was the page cache that was
messing with me :)

her is how the select event how to look like.


private void ListBox1_SelectedIndexChanged(object sender, System.EventArgs
e)
{
string tStr;
tStr = ListBox1.SelectedValue;
ListBox2.Items.Clear();
MyLinker.GetWebLinks(ref ListBox2, @"\\tim\RC Heli",
tStr);
}

private void ListBox2_SelectedIndexChanged(object sender, System.EventArgs
e)
{
if (Session["BeenHer"] == null){
Session.Add("BeenHer", false);
}
bool BeenHer = (bool) Session["BeenHer"];


if (Session["PreviousLink"] == null)
{
Session.Add("PreviousLink",
this.ListBox2.SelectedValue.ToString());
}
string tPrevLink = Session["PreviousLink"].ToString();

if (BeenHer && tPrevLink ==
this.ListBox2.SelectedValue.ToString())
{
ListBox2.ClearSelection();
BeenHer = false;
Session.Add("BeenHer", BeenHer);
}
else
{
string tStr = this.ListBox2.SelectedValue.ToString
();
BeenHer = true;
Session.Add("BeenHer", BeenHer);
Session.Add("PreviousLink",
this.ListBox2.SelectedValue.ToString());
Response.Redirect(tStr);
}
}
 
Back
Top